学生管理系统#define_CRT_SECURE_NO_WARNINGS#includestdio.h#includestdlib.h#includestring.hvoidAppendNode(longlongstudentID,charstudentName[10],charstudentSex[4],intscore[4]);//添加数据voidDisplayNode(structlink*head);//显示数据voidInsertNode(longlongstudentID,charstudentName[10],charstudentSex[4],intscore[4]);//插入一条数据;按总分的从大到小排序voidInsertNodeNumber(longlongstudentID,charstudentName[10],charstudentSex[4],intscore[4]);//按学号的从小到大排序voidNumberSorting(intflag);//按从大到小对数据进行排序;1、对总分进行排序,2、对学号进行排序voidDeleteNodeID();//输入学号删除voidDeleteNodeName();//输入学号删除voidDeleteMemory(structlink*head);//删除聊表所占用的内存;voidSave();//保存数据voidOpen();//打开数据voidFindID();//按学号查找学生voidFindName();//按姓名查找学生;voidMenu();typedefstructstudent{longlongstudentID;charstudentName[10];charstudentSex[4];intscore[4];}STU;structlink{STUstudent;structlink*next;};structlink*head=NULL;//保存输入的学生信息数据structlink*head1=NULL;//保存排序后的学生信息数据intmain(){longlongstudentID;charstudentName[10];charstudentSex[4];intscore[4];//定义要输入学生信息的变量;charc;intmenu;//保存要进行的选项;Open();while(1){system(pause);Menu();printf(请输入要进行的操作:);scanf(%d,&menu);switch(menu){case0:exit(0);break;case1:printf(请输入Y或y来添加数据\n);scanf(%c,&c);while(c=='y'||c=='Y'){printf(请输入学生学号:);scanf(%lld,&studentID);printf(请输入学生姓名:);scanf(%s,&studentName);printf(请输入学生性别:);scanf(%s,&studentSex);inti=0;printf(请分别输入学生四门课的成绩:);for(i=0;i4;i++){scanf(%d,&score[i]);}AppendNode(studentID,studentName,studentSex,score);printf(请输入Y或y来添加数据\n);scanf(%c,&c);}DisplayNode(head);break;case2:FindID();break;case3:FindName();break;case4:DeleteNodeID();break;case5:DeleteNodeName();case6:NumberSorting(1);DeleteMemory(head1);head1=NULL;break;case7:NumberSorting(2);DeleteMemory(head1);head1=NULL;break;default:printf(输入有误!请重新输入);}}Save();DeleteMemory(head);DeleteMemory(head1);system(pause);}voidAppendNode(longlongstudentID,charstudentName[10],charstudentSex[4],intscore[4]){structlink*p=NULL,*pr=head;p=(structlink*)malloc(sizeof(structlink));if(p==NULL){printf(申请内存失败);return;}if(head==NULL){head=p;}else{while(pr-next!=NULL){pr=pr-next;}pr-next=p;}p-student.studentID=studentID;strcpy(p-student.studentName,studentName);strcpy(p-student.studentSex,studentSex);p-student.score[0]=score[0];p-student.score[1]=score[1];p-student.score[2]=score[2];p-student.score[3]=score[3];p-next=NULL;return;}voidNumberSorting(intflag){structlink*p=head;structlink*p1=head1;intsum=0;if(p==NULL){printf(没有数据,无法排序);return;}while(p!=NULL){switch(flag){case1:InsertNode(p-student.studentID,p-student.studentName,p-student.studentSex,p-student.score);break;case2:InsertNodeNumber(p-student.studentID,p-student.studentName,p-student.studentSex,p-student.score);break;default:printf(程序异常,请重试!);break;}p=p-next;}DisplayNode(head1);}voidDisplayNode(structlink*head){structlink*p=head;if(p==NULL){return;}printf(%lld,p-student.studentID);printf(%10s,p-student.studentName);printf(%5s,p-student.studentSex);{inti=0;for(i=0;i4;i++){printf(%4d,p-student.score[i]);}}printf(\n);DisplayNode(p-next);}voidDeleteMemory(structlink*head){structlink*p=head,*pr=NULL;while(p!=NULL){pr=p;p=p-next;free(pr);}}voidInsertNodeNumber(longlongstudentID,charstudentName[10],charstudentSex[4],intscore[4]){structlink*pr=head1,*p=head1,*temp=NULL;p=(structlink*)malloc(sizeof(structlink));if(p==NULL){printf(内存申请失败);return;}p-next=NULL;p-student.studentID=studentID;strcpy(p-student.studentName,studentName);strcpy(p-student.studentSex,studentSex);p-student.score[0]=score[0];p-student.score[1]=score[1];p-student.score[2]=score[2];p-student.score[3]=score[3];if(head1==NULL){head1=p;}else{while(pr-student.studentIDstudentID&&pr-next!=NULL){temp=pr;pr=pr-next;}if(pr-student.studentID=studentID){if(pr==head1){p-next=head1;head1=p;}else{pr=temp;p-next=pr-next;pr-next=p;}}else{pr-next=p;}}return;}voidInsertNode(longlongstudentID,charstudentName[10],charstudentSex[4],intscore[4]){structlink*pr=head1,*p=head1,*temp=NULL;intsum,sum1;p=(structlink*)malloc(sizeof(structlink));if(p==NULL){printf(内存申请失败);return;}p-next=NULL;p-student.studentID=studentID;strcpy(p-student.studentName,studentName);strcpy(p-student.studentSex,studentSex);p-student.score[0]=score[0];p-student.score[1]=score[1];p-student.score[2]=score[2];p-student.score[3]=score[3];sum=p-student.score[0]+p-student.score[1]+p-student.score[2]+p-student.score[3];if(head1==NULL){head1=p;}else{sum1=pr-student.score[0]+pr-student.score[1]+pr-student.score[2]+pr-student.score[3];while(sum1sum&&pr-next!=NULL){temp=pr;pr=pr-next;sum1=pr-student.score[0]+pr-student.score[1]+pr-student.score[2]+pr-student.score[3];}if(sum1=sum){if(pr==head1){p-next=head1;head1=p;}else{pr=temp;p-next=pr-next;pr-next=p;}}else{pr-next=p;}}return;}voidDeleteNodeID()//输入学号删除{structlink*p=head,*pr=head;longlongstudentID=0;if(head==NULL){printf(对不起,没有数据可以删除);return;}printf(请输入你要删除的学生的学号);scanf(%s,studentID);while(studentID!=p-student.studentID&&p-next!=NULL){pr=p;p=p-next;}if(studentID==p-student.studentID){if(p==head){head=p-next;}else{pr