欢迎来到天天文库
浏览记录
ID:58584652
大小:30.50 KB
页数:8页
时间:2020-10-19
《基于单链表的学生信息管理系统源代码.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++;struc8、tstudent*p0,*p1,*p2;p1=head;p0=stu;if(head==NULL){head=p0;p0->next=NULL;}else{whil
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++;struc8、tstudent*p0,*p1,*p2;p1=head;p0=stu;if(head==NULL){head=p0;p0->next=NULL;}else{whil
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++;struc8、tstudent*p0,*p1,*p2;p1=head;p0=stu;if(head==NULL){head=p0;p0->next=NULL;}else{whil
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
此文档下载收益归作者所有