基于单链表的学生信息管理系统源代码.doc

基于单链表的学生信息管理系统源代码.doc

ID:58584652

大小:30.50 KB

页数:8页

时间:2020-10-19

基于单链表的学生信息管理系统源代码.doc_第1页
基于单链表的学生信息管理系统源代码.doc_第2页
基于单链表的学生信息管理系统源代码.doc_第3页
基于单链表的学生信息管理系统源代码.doc_第4页
基于单链表的学生信息管理系统源代码.doc_第5页
资源描述:

《基于单链表的学生信息管理系统源代码.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、//学生信息管理系统#include#include#include#defineNULL0#defineLENsizeof(structstudent)//建立动态链表.cppusingnamespacestd;structstudent{intnum;charname[20];charsex[5];floatmath;floatenglish;intorder;structstudent*next;};intn;intmale=0;intfamale=0;structstudent

2、*creat(void){structstudent*head,*p1,*p2;n=0;p1=p2=(structstudent*)malloc(LEN);cout<<"下面开始创建链表:"<>p1->num>>p1->name>>p1->sex>>p1->math>>p1->english;head=NULL;while(p1->num!=0){if(strcmp(p1->sex,"男")==0)male++;elsefamale++;n+

3、+;if(n==1)head=p1;elsep2->next=p1;p2=p1;p1=(structstudent*)malloc(LEN);cin>>p1->num>>p1->name>>p1->sex>>p1->math>>p1->english;}p2->next=NULL;if(head==NULL){cout<<"创建失败,请重建:"<

4、<"学号"<<"姓名"<<"性别"<<"数学"<<"英语"<<"总分"<num<name<sex<math<english<math+p->english<

5、dl;p=p->next;}while(p!=NULL);}//链表结点的删除操作structstudent*del(structstudent*head){if(n==0){cout<<"无链表可删除"<>num;while(num!=0){structstudent*p1,*p2;p1=head;while(num!=p1->num&&p1->next!=NULL){p2=p1;p1=p1->next;}if(num==p1->num){if(p1=

6、=head){if(strcmp(p1->sex,"男")==0)male--;elsefamale--;head=p1->next;}else{if(strcmp(p1->sex,"男")==0)male--;elsefamale--;p2->next=p1->next;}cout<>num;}if(n==0){cout<<"此时链表已为空!"<

7、}//插入结点structstudent*insert(structstudent*head){structstudent*stu;stu=(structstudent*)malloc(LEN);cout<<"学号"<<"姓名"<<"性别"<<"数学"<<"英语"<>stu->num>>stu->name>>stu->sex>>stu->math>>stu->english;while(stu->num!=0){if(strcmp(stu->sex,"男")==0)male++;elsefamale++;n++;struc

8、tstudent*p0,*p1,*p2;p1=head;p0=stu;if(head==NULL){head=p0;p0->next=NULL;}else{whil

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

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

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