学生课程管理

学生课程管理

ID:39640017

大小:40.50 KB

页数:4页

时间:2019-07-08

学生课程管理_第1页
学生课程管理_第2页
学生课程管理_第3页
学生课程管理_第4页
资源描述:

《学生课程管理》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、#include#includetypedefstructstudent{longintnum;charname[20];structstudent*next;}stud;stud*create_list();intinsert_list(stud*head,char*name,intn);intdel_list(stud*head,char*name);stud*find_list(stud*head,char*name);voidbrow_list(stud*head

2、);voidmain(){stud*head;intchoice;charname[8];head=NULL;cout<<"1.建立链表";cout<<"2.插入新生";cout<<"3.查找学生";cout<<"4.删除学生";cout<<"5.数据浏览";cout<<"0.退出程序";do{cout<<"请选择操作(输入0-5)";cin>>choice;if(choice>5

3、

4、choice<0){cout<<"输入错误!a";continue;}switch(choice)

5、{case1:if(head==NULL)head=create_list();break;case2:if(head==NULL){cout<<"链表未建立!";break;}while(1){cout<<"姓名(输入0结束):";cin>>name;if(strcmp(name,"0")==0)break;insert_list(head,name,-1);}break;case3:cout<<"输入姓名:";cin>>name;find_list(head,name);break;case4:cout<<

6、"输入姓名:";cin>>name;del_list(head,name);break;case5:brow_list(head);break;default:return;}}while(1);}stud*create_list(){stud*head;head=newstud;if(head!=NULL)cout<<"链表已建立!";elsecout<<"没有足够内存空间!a";head->next=NULL;head->num=0;returnhead;}intinsert_list(stud*he

7、ad,char*name,intn){stud*p,*q,*s;s=newstud;if(s==NULL){cout<<"没有足够内存空间!a";return0;}q=head;p=head->next;while(p!=NULL&&n!=q->num){q=p;p=p->next;}q->next=s;s->next=p;strcpy(s->name,name);s->num=q->num+1;return1;}stud*find_list(stud*head,char*name){stud*p;p=hea

8、d;while(p!=NULL&&strcmp(p->name,name)){p=p->next;}if(p!=NULL){cout<<"学号:"<num<<"姓名:"<name<<"";}elsecout<<"查无此人!";returnp;}intdel_list(stud*head,char*name){stud*p,*q;q=head;p=head->next;while(p!=NULL&&strcmp(p->name,name)){q=p;p=p->next;}if(p!=NULL)

9、{q->next=p->next;deletep;cout<<"删除完成!";return1;}else{cout<<"查无此人!a";return0;}}voidbrow_list(stud*head){stud*p;p=head->next;while(p!=NULL){cout<<"学号:"<num<<"姓名:"<name<<"";p=p->next;}}

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。