首页 > 分享 > 我的编号

我的编号

我的编号

最新推荐文章于 2023-03-18 11:33:12 发布

夏芷雨涵梦 于 2017-03-24 12:42:00 发布

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

题目描述:


代码:

#include <iostream>

#include <string.h>

using namespace std;

struct student

{

int number;

char name[20];

student *next;

};

student *createlist(int n)

{

int i;

student *head=NULL;

student *p=NULL;

head=new student;

head->next=NULL;

p=head;

cin>>p->number>>p->name;

for(i=1;i<n;i++)

{

p->next=new student;

p=p->next;

p->next=NULL;

cin>>p->number>>p->name;

}

return head;

}

void searchstu(student *head,char *str)

{

student *current;

current=head;

while(current!=NULL)

{

if(!strcmp(current->name,str))

{

cout<<current->number<<endl;

break;

}

else

current=current->next;

}

}

void destroy(student *head)

{

student *p;

p=head;

while(head!=NULL)

{

p=head;

head=head->next;

delete p;

}

}

int main()

{

int n;

char str[20];

student *head;

cin>>n;

head=createlist(n);

cin>>str;

searchstu(head,str);

destroy(head);

return 0;

}

结果展示:


相关知识

编号:GDZPS10...
Flowers 花盆装饰装修素材免费下载(图片编号:3869781)
绿色鲜花婚礼现场效果图平面广告素材免费下载(图片编号:4824896)
道路花带绿化设计装饰装修素材免费下载(图片编号:4789356)
淘宝永生花全屏轮播电商淘宝素材免费下载(图片编号:5292406)
我最喜欢的花卉手抄报 花卉知识手抄报
医疗器械产品技术要求编号
矢量浪漫花卉炫彩背景设计元素素材免费下载(图片编号:2332229)
河南省农作物种子标签检疫证明编号暂行管理办法
编号:GDZPS76...

网址: 我的编号 https://m.huajiangbk.com/newsview462843.html

所属分类:花卉
上一篇: PAT1004
下一篇: 黑胶唱片=70年代黑胶唱片=歌曲