学生信息管理系统
来源:互联网 发布:软件开发的文档 编辑:程序博客网 时间:2024/05/16 05:27
初学编程答辩用的学生信息管理系统
说明:在学习完C语言之后学院要求我们三人一组,做系统来答辩,其中有图书馆信息管理系统,学生信息管理系统,酒店管理系统可选择。当时我们组选择的是学生信息管理系统,由于时间匆忙,而且当时水平也不是很高,所以代码有些凌乱,不过功能上还是齐全的,其中有:从文件读取信息,从键盘读取信息,增加信息,删除信息,查找信息,排序,输出信息等。具体的以后运行一下就知道了。
以下是代码:
#include<stdio.h> //包涵基本的输入输出#include<stdlib.h> //包涵控制循环退出等函数#include<malloc.h> //开辟新节点的头文件#include<string.h> //字符处理的头文件#define LEN sizeof(struct node) //宏定义LEN---------后期程序稍简洁#define HEADER1 " ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━STUDENT━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n"#define HEADER11 " \t┃\t\t\t┏━━━━━━━┳━━━━┳━━━┳━━━━┳━━━━┳━━━━┳━━━━┳━━━━┓\t\t\t ┃\n"#define HEADER2 " \t┃\t\t\t┃ 学号 ┃ 姓名 ┃C成绩 ┃数学成绩┃英语成绩┃ 总分 ┃ 平均分 ┃ 排名 ┃\t\t\t ┃\n"#define HEADER3 " \t┃\t\t\t┣━━━━━━━╋━━━━╋━━━╋━━━━╋━━━━╋━━━━╋━━━━╋━━━━┫\t\t\t ┃\n"#define FORMAT " \t┃\t\t\t┃%-14s┃%-8s┃ %-4d┃ %-5d┃ %-5d┃ %-6d┃ %-7.2f┃ %-5d┃\t\t\t ┃\n"#define DATA pt->data.num,pt->data.name,pt->data.cgrade,pt->data.mgrade,pt->data.egrade,pt->data.total,pt->data.ave,pt->data.ranking#define END " \t┃\t\t\t┗━━━━━━━┻━━━━┻━━━┻━━━━┻━━━━┻━━━━┻━━━━┻━━━━┛\t\t\t ┃\n"#define HEADEng " \t┃\t\t\t┃ Num ┃ Name ┃ C ┃ Math ┃English ┃ Total ┃Average ┃ Ranking┃\t\t\t ┃\n"/**********全局声明***********/int selectx;//select主菜单选择int u;//u选择系统语言,int saveflag=0;//是否需要存盘的标志变量int Cfail=0,Efail=0,Mfail=0;//记录各科不及格人数int count=0;/******定义结构体****************/struct student{ char num[17];//保存学号 char name[20];//保存姓名 int cgrade;//保存C语言成绩 int mgrade;//保存数学成绩 int egrade;//保存英语成绩 int total;//保存总分 double ave;//保存平均分 int ranking;//保存名次};/*******定义结构体链表*************************/struct node{ struct student data;//student结构类型的数据 struct node *next;//单链表中的指针域}Node,*Link;//Node为node类型的结构变量、*Link为node类型的指针变量//全局声明链表头节点struct node *head=NULL;//声明C语言科不及格学生信息的头结点struct node *Chead=NULL;//声明英语科不及格学生信息的头结点struct node *Ehead=NULL;//声明数学科不及格学生信息的头结点struct node *Mhead=NULL;//从键盘读取数据到链表的函数,若链表不为空时判断是否覆盖信息struct node *AddKeyboard(void){ int keyX=0; if(saveflag==1) { if(u==1) printf("是否覆盖之前的学生信息?(1.是/0.否)\n\t"); else printf("If information before?(1.YES/0.NO)"); scanf("%d",&keyX); if(keyX==1) { count=0; if(u==1) printf("\t正在从键盘读取数据。 ^_^\n\n\t输入 # 结束输入。 ^_^\n"); else printf("\tData is read from the file. ^_^\n\n\tEnter # input end. ^_^\n"); struct node *p1,*p2; int n=0; p1=p2=(struct node *)malloc(LEN); if(u==1) printf("\n\n\t请输入学生学号:"); else printf("\n\n Please enter the student student id:"); scanf("%s",p1->data.num); if(p1->data.num[0]=='#') { head=NULL; return head; } else { if(u==1) { printf("\n\t请输入学生姓名:"); scanf("%s",p1->data.name); printf("\n\t请输入C课程成绩(0--100):"); scanf("%d",&p1->data.cgrade); printf("\n\t请输入数学课程的成绩(0--100):"); scanf("%d",&p1->data.mgrade); printf("\n\t请输入英语课程的成绩(0--100):"); scanf("%d",&p1->data.egrade); } else { printf("\n Please enter the student's name:"); scanf("%s",p1->data.name); printf("\n Please enter the C language(0--100):"); scanf("%d",&p1->data.cgrade); printf("\n Please enter the mathematics course grades(0--100):"); scanf("%d",&p1->data.mgrade); printf("\n Please enter the English course(0--100):"); scanf("%d",&p1->data.egrade); } p1->data.total=((p1->data.cgrade)+(p1->data.mgrade)+(p1->data.egrade)); p1->data.ave=(p1->data.total/3.0); p1->data.ranking=0; count++; head=NULL; while(1) { system("cls"); if(u==1) printf("\t正在从键盘读取数据。 ^_^\n\n\t输入 # 结束输入。 ^_^\n"); else printf("\tData is read from the file. ^_^\n\n\tEnter # input end. ^_^\n"); n=n+1; if(n==1) head=p1; else p2->next=p1; p2=p1; p1=(struct node *)malloc(LEN); if(u==1) printf("\n\n\t请输入学生学号:"); else printf("\n\n Please enter the student student id:"); scanf("%s",p1->data.num); if(p1->data.num[0]=='#') { p2->next=NULL; saveflag=1; return head; } if(u==1) { printf("\n\t请输入学生姓名:"); scanf("%s",p1->data.name); printf("\n\t请输入C课程成绩(0--100):"); scanf("%d",&p1->data.cgrade); printf("\n\t请输入数学课程的成绩(0--100):"); scanf("%d",&p1->data.mgrade); printf("\n\t请输入英语课程的成绩(0--100):"); scanf("%d",&p1->data.egrade); } else { printf("\n Please enter the student's name:"); scanf("%s",p1->data.name); printf("\n Please enter the C language(0--100):"); scanf("%d",&p1->data.cgrade); printf("\n Please enter the mathematics course grades(0--100):"); scanf("%d",&p1->data.mgrade); printf("\n Please enter the English course(0--100):"); scanf("%d",&p1->data.egrade); } p1->data.total=((p1->data.cgrade)+(p1->data.mgrade)+(p1->data.egrade)); p1->data.ave=(p1->data.total/3.0); p1->data.ranking=0; count++; } p2->next=NULL; } } else { struct node *pt; pt=head; while(pt->next!=NULL) {pt=pt->next;} if(u==1) printf("\t正在从键盘读取数据。 ^_^\n\n\t输入 # 结束输入。 ^_^\n"); else printf("\tData is read from the file. ^_^\n\n\tEnter # input end. ^_^\n"); struct node *a1,*a2,*lianjie; int n=0; a1=a2=(struct node *)malloc(LEN); if(u==1) printf("\n\n\t请输入学生学号:"); else printf("\n\n Please enter the student student id:"); scanf("%s",a1->data.num); if(a1->data.num[0]=='#') { lianjie=NULL; pt->next=lianjie; return head; } else { if(u==1) { printf("\n\t请输入学生姓名:"); scanf("%s",a1->data.name); printf("\n\t请输入C课程成绩(0--100):"); scanf("%d",&a1->data.cgrade); printf("\n\t请输入数学课程的成绩(0--100):"); scanf("%d",&a1->data.mgrade); printf("\n\t请输入英语课程的成绩(0--100):"); scanf("%d",&a1->data.egrade); } else { printf("\n Please enter the student's name:"); scanf("%s",a1->data.name); printf("\n Please enter the C language(0--100):"); scanf("%d",&a1->data.cgrade); printf("\n Please enter the mathematics course grades(0--100):"); scanf("%d",&a1->data.mgrade); printf("\n Please enter the English course(0--100):"); scanf("%d",&a1->data.egrade); } a1->data.total=((a1->data.cgrade)+(a1->data.mgrade)+(a1->data.egrade)); a1->data.ave=(a1->data.total/3.0); a1->data.ranking=0; count++; lianjie=NULL; while(1) { system("cls"); if(u==1) printf("\t正在从键盘读取数据。 ^_^\n\n\t输入 # 结束输入。 ^_^\n"); else printf("\tData is read from the file. ^_^\n\n\tEnter # input end. ^_^\n"); n=n+1; if(n==1) lianjie=a1; else a2->next=a1; a2=a1; a1=(struct node *)malloc(LEN); if(u==1) printf("\n\n\t请输入学生学号:"); else printf("\n\n Please enter the student student id:"); scanf("%s",a1->data.num); if(a1->data.num[0]=='#') { a2->next=NULL; pt->next=lianjie; saveflag=1; return head; } if(u==1) { printf("\n\t请输入学生姓名:"); scanf("%s",a1->data.name); printf("\n\t请输入C课程成绩(0--100):"); scanf("%d",&a1->data.cgrade); printf("\n\t请输入数学课程的成绩(0--100):"); scanf("%d",&a1->data.mgrade); printf("\n\t请输入英语课程的成绩(0--100):"); scanf("%d",&a1->data.egrade); } else { printf("\n Please enter the student's name:"); scanf("%s",a1->data.name); printf("\n Please enter the C language(0--100):"); scanf("%d",&a1->data.cgrade); printf("\n Please enter the mathematics course grades(0--100):"); scanf("%d",&a1->data.mgrade); printf("\n Please enter the English course(0--100):"); scanf("%d",&a1->data.egrade); } a1->data.total=((a1->data.cgrade)+(a1->data.mgrade)+(a1->data.egrade)); a1->data.ave=(a1->data.total/3.0); a1->data.ranking=0; count++; } a2->next=NULL; } } } else { if(u==1) printf("\t正在从键盘读取数据。 ^_^\n\n\t输入 # 结束输入。 ^_^\n"); else printf("\tData is read from the file. ^_^\n\n\tEnter # input end. ^_^\n"); struct node *p1,*p2; int n=0; p1=p2=(struct node *)malloc(LEN); if(u==1) printf("\n\n\t请输入学生学号:"); else printf("\n\n Please enter the student student id:"); scanf("%s",p1->data.num); if(p1->data.num[0]=='#') { head=NULL; return head; } else { if(u==1) { printf("\n\t请输入学生姓名:"); scanf("%s",p1->data.name); printf("\n\t请输入C课程成绩(0--100):"); scanf("%d",&p1->data.cgrade); printf("\n\t请输入数学课程的成绩(0--100):"); scanf("%d",&p1->data.mgrade); printf("\n\t请输入英语课程的成绩(0--100):"); scanf("%d",&p1->data.egrade); } else { printf("\n Please enter the student's name:"); scanf("%s",p1->data.name); printf("\n Please enter the C language(0--100):"); scanf("%d",&p1->data.cgrade); printf("\n Please enter the mathematics course grades(0--100):"); scanf("%d",&p1->data.mgrade); printf("\n Please enter the English course(0--100):"); scanf("%d",&p1->data.egrade); } p1->data.total=((p1->data.cgrade)+(p1->data.mgrade)+(p1->data.egrade)); p1->data.ave=(p1->data.total/3.0); p1->data.ranking=0; count++; head=NULL; while(1) { system("cls"); if(u==1) printf("\t正在从键盘读取数据。 ^_^\n\n\t输入 # 结束输入。 ^_^\n"); else printf("\tData is read from the file. ^_^\n\n\tEnter # input end. ^_^\n"); n=n+1; if(n==1) head=p1; else p2->next=p1; p2=p1; p1=(struct node *)malloc(LEN); if(u==1) printf("\n\n\t请输入学生学号:"); else printf("\n\n Please enter the student student id:"); scanf("%s",p1->data.num); if(p1->data.num[0]=='#') { p2->next=NULL; saveflag=1; return head; } if(u==1) { printf("\n\t请输入学生姓名:"); scanf("%s",p1->data.name); printf("\n\t请输入C课程成绩(0--100):"); scanf("%d",&p1->data.cgrade); printf("\n\t请输入数学课程的成绩(0--100):"); scanf("%d",&p1->data.mgrade); printf("\n\t请输入英语课程的成绩(0--100):"); scanf("%d",&p1->data.egrade); } else { printf("\n Please enter the student's name:"); scanf("%s",p1->data.name); printf("\n Please enter the C language(0--100):"); scanf("%d",&p1->data.cgrade); printf("\n Please enter the mathematics course grades(0--100):"); scanf("%d",&p1->data.mgrade); printf("\n Please enter the English course(0--100):"); scanf("%d",&p1->data.egrade); } p1->data.total=((p1->data.cgrade)+(p1->data.mgrade)+(p1->data.egrade)); p1->data.ave=(p1->data.total/3.0); p1->data.ranking=0; count++; } p2->next=NULL; } }}/*****************系统语言提示******************************/void LanguageTips(){ printf("\t\t\t◎★★★★★★★★★★★★★★★★★★★★★★★★◎\n"); printf("\t\t\t◎★★★★【 请选择系统语言 】★★★★◎\n"); printf("\t\t\t◎★★★★【 1、中文系统 】★★★★◎\n"); printf("\t\t\t◎★★★★【 2、English system 】★★★★◎\n"); printf("\t\t\t◎★★★★★★★★★★★★★★★★★★★★★★★★◎\n"); printf("\n\t\t\t\n\t\t请选择系统语言:");}/****************主菜单**********************************/void ShowMenu() { system("COLOR b0"); system("mode con cols=79 lines=30"); if(u==1) { printf("\t\t========>>>>>====共有%d个学生记录====>>>>> ^_^\n\n",count); printf("〓〓〓〓〓〓〓〓〓★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓★〓◎☆ 学 生 成 绩 管 理 系 统 ☆◎〓★〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓★★★★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓〓★◎☆ ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓〓★◎☆ 1.新建学生记录 ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓〓★◎☆ 2.删除学生记录 ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓〓★◎☆ 3.查询学生记录 ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓〓★◎☆ 4.修改学生记录 ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓〓★◎☆ 5.插入学生信息 ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓〓★◎☆ 6.统计学生信息 ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓〓★◎☆ 7.降序排序操作 ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓〓★◎☆ 8.保存学生信息 ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓〓★◎☆ 9.输出记录到屏幕 ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓〓★◎☆ 10.返回上一页 ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓〓★◎☆ 0.安全退出系统 ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓〓★◎☆ ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓〓★◎☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓〓★◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓〓★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓〓〓〓\n"); printf("\t\t\n\t\t请输入相应数字选择该功能:\n\t\t"); } else { printf("\t========>>>>>====A total of %d student record.====>>>>> ^_^\n\n",count); printf("〓〓〓〓〓〓〓★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★◎◎☆ Menu ☆◎◎★〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓★★★★★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓★◎☆ ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓★◎☆ 1.Input record ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓★◎☆ 2.Delete record ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓★◎☆ 3.Search record ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓★◎☆ 4.Modify record ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓★◎☆ 5.Insert record ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓★◎☆ 6.Count record ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓★◎☆ 7.Sort record ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓★◎☆ 8.Save record ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓★◎☆ 9.Display record ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓★◎☆ 10.Return step ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓★◎☆ 0.Quit record ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓★◎☆ ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓★◎☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓★◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓〓〓〓\n"); printf("\t\n\tPlease enter the corresponding number select the function:\n\t\t"); }}//错误提示,在按键不符合菜单提时调用该函数void Wrong(){ system("cls"); if(u==1) { printf("\n\n\n\n\n\n\t\t\tT_T 按键有误,请重新输入!\n"); printf("\n\t\t\tT_T 或者没有相关数据,请录入数据!\n\n\t\t"); } else { printf("\n\n\n\n\n\t\terror:T_T input has wrong! press any key to continiue!\n"); printf("\n\t\tOr no relevant data, please input data.\n\n\t\t"); } system("pause"); fflush(stdin); system("cls");}//将获得的节点的数据以表格方式输出到屏幕void DispCout(struct node *print){ system("mode con cols=150 lines=50"); struct node *pt; pt=print; system("cls"); if(print==NULL) { if(u==1) printf("没有相关数据! T_T "); else printf("Without access to relevant data! T_T"); } else{ printf(HEADER1); printf(HEADER11); if(u==1) printf(HEADER2); else printf(HEADEng); printf(HEADER3); printf(FORMAT,DATA); printf(END); } system("pause");}//将获得的节点后面的所有数据以表格方式输出到屏幕void Disp(struct node *print){ system("mode con cols=150 lines=9999"); struct node *pt; pt=print; system("cls"); if(pt==NULL) Wrong(); else { printf(HEADER1); printf(HEADER11); if(u==1) printf(HEADER2); else printf(HEADEng); while(pt!=NULL) { printf(HEADER3); printf(FORMAT,DATA); pt=pt->next; } printf(END); } if(u==1) printf("\n\t总共有 %d 个学生记录。\n\t",count); else printf("\n\tA total of %d student record.\n\t",count); system("pause");}void QurMenu()//查询学生信息的菜单{ system("COLOR F6"); if(u==1) { system("mode con cols=83 lines=30"); printf("\t\t========>>>>>====共有%d个学生记录====>>>>> ^_^\n\n",count); printf("〓〓〓〓〓〓〓〓〓★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓★〓◎☆ 查询菜单 ☆◎〓★〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓★★★★★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓〓★◎☆ ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓〓★◎☆ 1.按学生学号查询 ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓〓★◎☆ 2.按学生姓名查询 ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓〓★◎☆ 3.按学生名次查询 ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓〓★◎☆ 0.返回上一页 ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓〓★◎☆ ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓〓★◎☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓〓★◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓〓★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓〓〓〓\n"); printf("\t\t\n\t\t请输入相应数字选择该功能:"); } else { system("mode con cols=90 lines=30"); printf("\t========>>>>>====A total of %d student record.====>>>>> ^_^\n\n",count); printf("〓〓〓〓〓★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓★〓◎☆ Query menu ☆◎〓★〓〓〓〓〓〓〓〓\n"); printf("〓〓〓★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓★◎☆ ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓★◎☆ 1.According to the student number query ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓★◎☆ 2.According to the student's name query ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓★◎☆ 3.According to the students rank query ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓★◎☆ 0.Return to the previous page ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓★◎☆ ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓★◎☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓★◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓〓〓〓\n"); printf("\t\n\tPlease enter the corresponding number select the function:"); }}struct node *QurRank()//根据排名查询的主控函数{ struct node *pt; struct node *N=NULL; //不能直接对头指针进行操作,要不然整个链表就没了 pt=head; int rank; //使用学号来查找 if(u==1) printf("\t请输入想查找的排名:"); else printf("\tPlease input to search rankings:"); scanf("%d",&rank); //输入要查找的人的学号 while(pt!=NULL) { if(pt->data.ranking==rank) { N=pt; break; } pt=pt->next; } return N;}struct node *QurNumber()//按学生学号查询学生信息{ struct node *pt; struct node *N=NULL; //不能直接对头指针进行操作,要不然整个链表就没了 int i; pt=head; char numx[15],n[15]; //使用学号来查找 if(u==1) printf("\t请输入学号:"); else printf("\tinput a number:"); scanf("%s",numx); //输入要查找的人的学号 while(pt!=NULL) { strcpy(n,pt->data.num); i=strcmp(n,numx); if(i==0) { N=pt; break; } pt=pt->next; } return N;}struct node *QurName()//按学生姓名查询学生信息{ struct node *pt; struct node *M=NULL; //不能直接对头指针进行操作,要不然整个链表就没了 int i; pt=head; char namex[15],n[15]; //使用姓名来查找 if(u==1) printf("\t请输入姓名:"); else printf("\tPlease input your name:"); scanf("%s",namex); //输入要查找的人的姓名 while(pt!=NULL) { strcpy(n,pt->data.name); i=strcmp(n,namex); if(i==0) { M=pt; break; } pt=pt->next; } return M;}//查询学生信息的主控函数void Qur(){ int QurX; struct node *cout; system("cls"); QurMenu(); scanf("%d",&QurX);//输入菜单选择项 switch(QurX) { case 1: { cout=QurNumber(); DispCout(cout); break; } case 2: { cout=QurName(); DispCout(cout); break; } case 3: { cout=QurRank(); DispCout(cout); break; } case 0:break; default:Wrong();break; } system("pause"); system("cls");}//修改学生信息的菜单void ModifyMenu(){ system("COLOR 3E"); system("mode con cols=83 lines=30"); if(u==1) { printf("\t\t========>>>>>====共有%d个学生记录====>>>>> ^_^\n\n",count); printf("〓〓〓〓〓★★★★★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓★〓◎☆ 修改记录 ☆◎〓★〓〓〓〓〓〓〓〓\n"); printf("〓〓〓★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓★◎☆ ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓★◎☆ 1.按学生具体学号修改学生信息 ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓★◎☆ 2.按学生具体姓名修改学生信息 ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓★◎☆ 0.返回上一页 ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓★◎☆ ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓★◎☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓★◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓★★★★★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓〓〓〓\n"); printf("\t\t\n\t\t请输入相应数字选择该功能:"); } else { printf("\t========>>>>>====A total of %d student record.====>>>>> ^_^\n\n",count); printf("〓〓〓〓〓〓★★★★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓★〓◎☆ Modify the record ☆◎〓★〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓★★★★★★★★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★◎☆ ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★◎☆ 1.According to the student id ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★◎☆ 2.According to the name ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★◎☆ 0.Return to the previous page ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★◎☆ ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★◎☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★★★★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓〓〓〓\n"); printf("\t\n\tPlease enter the corresponding number select the function:"); }}//按学生学号找出学生信息并修改struct node *ModifyNumber(){ struct node *pt2;xiugai1: pt2=QurNumber(); if(pt2!=NULL) { DispCout(pt2); if(u==1) { printf("\t已找到该学生,请重新输入该学生的信息:"); printf("\n\n\t请输入学生学号:"); scanf("%s",pt2->data.num); printf("\n\t请输入学生姓名:"); scanf("%s",pt2->data.name); printf("\n\t请输入C课程成绩(0--100):"); scanf("%d",&pt2->data.cgrade); printf("\n\t请输入数学课程的成绩(0--100):"); scanf("%d",&pt2->data.mgrade); printf("\n\t请输入英语课程的成绩(0--100):"); scanf("%d",&pt2->data.egrade); } else { printf("\tPlease enter the student information again:"); printf("\n\n Please enter the student student id:"); scanf("%s",pt2->data.num); printf("\n Please enter the student's name:"); scanf("%s",pt2->data.name); printf("\n Please enter the C language(0--100):"); scanf("%d",&pt2->data.cgrade); printf("\n Please enter the mathematics course grades(0--100):"); scanf("%d",&pt2->data.mgrade); printf("\n Please enter the English course(0--100):"); scanf("%d",&pt2->data.egrade); } pt2->data.total=((pt2->data.cgrade)+(pt2->data.mgrade)+(pt2->data.egrade)); pt2->data.ave=(pt2->data.total/3.0); saveflag=1; } else { Wrong(); goto xiugai1; } return head;}struct node *ModifyName()//按学生姓名找出学生信息并修改{ struct node *pt1;xiugai2: pt1=QurName(); if(pt1!=NULL) { DispCout(pt1); if(u==1) { printf("\t已找到该学生,请重新输入该学生的信息:"); printf("\n\n\t请输入学生学号:"); scanf("%s",pt1->data.num); printf("\n\t请输入学生姓名:"); scanf("%s",pt1->data.name); printf("\n\t请输入C课程成绩(0--100):"); scanf("%d",&pt1->data.cgrade); printf("\n\t请输入数学课程的成绩(0--100):"); scanf("%d",&pt1->data.mgrade); printf("\n\t请输入英语课程的成绩(0--100):"); scanf("%d",&pt1->data.egrade); } else { printf("\tPlease enter the student information again:"); printf("\n\n Please enter the student student id:"); scanf("%s",pt1->data.num); printf("\n Please enter the student's name:"); scanf("%s",pt1->data.name); printf("\n Please enter the C language(0--100):"); scanf("%d",&pt1->data.cgrade); printf("\n Please enter the mathematics course grades(0--100):"); scanf("%d",&pt1->data.mgrade); printf("\n Please enter the English course(0--100):"); scanf("%d",&pt1->data.egrade); } pt1->data.total=((pt1->data.cgrade)+(pt1->data.mgrade)+(pt1->data.egrade)); pt1->data.ave=(pt1->data.total/3.0); saveflag=1; } else {Wrong();goto xiugai2;} return head;}void Modify()//修改学生信息的主控函数{ int ModifyX; system("cls"); ModifyMenu(); scanf("%d",&ModifyX);//输入菜单选择项 switch(ModifyX) { case 1: { Disp(ModifyNumber()); break; } case 2: { Disp(ModifyName()); break; } case 0:break; default:Wrong();break; } system("pause"); system("cls");}//保存学生信息模块菜单void SaveMenu(){ system("COLOR 5b"); system("mode con cols=82 lines=30"); if(u==1) { printf("\t\t========>>>>>====共有%d个学生记录====>>>>> ^_^\n\n",count); printf("〓〓〓〓〓★★★★★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓★〓◎☆ 保存数据方式 ☆◎〓★〓〓〓〓〓〓〓〓\n"); printf("〓〓〓★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓★◎☆ ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓★◎☆ 1.以表格方式保存到文件 ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓★◎☆ 2.以固定格式保存文件 ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓★◎☆ 0.返回上一页 ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓★◎☆ ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓★◎☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓★◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓★★★★★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓〓〓〓\n"); printf("\n\t以表格方式保存将不可读取到系统中!\n\t"); printf("\n\t以固定格式保存文件可再次读取到系统中。\n\t"); printf("\t\t\n\t\t请输入相应数字选择该功能:"); } else { printf("\t========>>>>>====A total of %d student record.====>>>>> ^_^\n\n",count); printf("〓〓〓〓〓〓★★★★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓★〓◎☆ Output recording mode ☆◎〓★〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓★★★★★★★★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★◎☆ ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★◎☆ 1.Save to file in table manner ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★◎☆ 2.To save the file format the way ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★◎☆ 0.Return to the previous page ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★◎☆ ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★◎☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★★★★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓〓〓〓\n"); printf("\n\tIn table manner will not read to the system!\n\t"); printf("\n\tSave the file again entry system in fixed format!\n\t"); printf("\t\n\tPlease enter the corresponding number select the function:\n\t"); }}//以格式化方式保存学生信息到txt文件功能函数(可读取)void SaveOutputFormatting() { FILE *write; char filename[20]; struct node *pt; if (head == NULL) //对空链表进行处理 { if(u==1) printf("\t没有学生信息,保存失败 T_T \n "); else printf("\tNo student information, save failed T_T \n "); system("pause"); return; } pt=head; if(u==1) printf("\t请输入保存的文件名(如save): "); else printf("Please enter a save file name (such as save): "); while(!scanf("%s",filename)) //接受文件名,并进行排错(几乎不会出现错误的现象,慎重而设) { if(u==1) printf("\t输入文件名有误,请重新输入 T_T : "); else printf("\tEnter the file name is wrong, please input again T_T :"); } strcat(filename,".txt"); //链接后缀名 write = fopen(filename,"w"); //以写入方式打开文件 while(pt!=NULL) { if(pt->next!=NULL) fprintf(write,"%-14s\t%-8s%-4d%-5d%d\n",pt->data.num,pt->data.name,pt->data.cgrade,pt->data.mgrade,pt->data.egrade); else fprintf(write,"%-14s\t%-8s%-4d%-5d%d",pt->data.num,pt->data.name,pt->data.cgrade,pt->data.mgrade,pt->data.egrade); pt=pt->next; } fclose(write); //关闭文件 saveflag=0; if(u==1) printf("\t保存成功! ^_^ \n "); else printf("\tSave the success! ^_^ \n"); system("pause");}void SaveOutputTable() //以表格方式保存学生信息到txt文件功能函数(不可读取){ FILE *write; char filename[20]; struct node *pt; if (head == NULL) //对空链表进行处理 { if(u==1) printf("\t没有学生信息,保存失败 T_T \n "); else printf("\tNo student information, save failed T_T \n "); system("pause"); return; } pt=head; if(u==1) printf("\t请输入保存的文件名(如save): "); else printf("Please enter a save file name (such as save): "); while(!scanf("%s",filename)) //接受文件名,并进行排错(几乎不会出现错误的现象,慎重而设) { if(u==1) printf("\t输入文件名有误,请重新输入 T_T : "); else printf("\tEnter the file name is wrong, please input again T_T :"); } strcat(filename,".txt"); //链接后缀名 write = fopen(filename,"w"); //以写入方式打开文件 //***********************表格头部设计************************ fprintf(write,HEADER1); fprintf(write,HEADER11); if(u==1) fprintf(write,HEADER2); else fprintf(write,HEADEng); //***********************表格内容设计************************ while(pt!=NULL) { fprintf(write,HEADER3); fprintf(write,FORMAT,DATA); pt=pt->next; } //***********************表格尾部部设计************************ fprintf(write,END); fclose(write); //关闭文件 saveflag=0; if(u==1) printf("\t保存成功! ^_^ \n "); else printf("\tSave the success! ^_^ \n"); system("pause");}void Save()//保存学生信息的主控函数{ int OutM; system("cls"); SaveMenu(); scanf("%d",&OutM); switch(OutM) { case 1:{SaveOutputTable();break;} case 2:{SaveOutputFormatting();break;} case 0:break; default:Wrong();break; } system("pause"); system("cls");}void DelMenu()//删除学生信息的菜单{ system("COLOR F3"); system("mode con cols=81 lines=30"); if(u==1) { printf("\t\t========>>>>>====共有%d个学生记录====>>>>> ^_^\n\n",count); printf("〓〓〓〓〓★★★★★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓★〓◎☆ 删除记录 ☆◎〓★〓〓〓〓〓〓〓〓\n"); printf("〓〓〓★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓★◎☆ ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓★◎☆ 1.按学生具体学号删除学生信息 ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓★◎☆ 2.按学生具体姓名删除学生信息 ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓★◎☆ 0.返回上一页 ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓★◎☆ ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓★◎☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓★◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓★★★★★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓〓〓〓\n"); printf("\t\t\n\t\t请输入相应数字选择该功能:"); } else { printf("\t========>>>>>====A total of %d student record.====>>>>> ^_^\n\n",count); printf("〓〓〓〓〓〓★★★★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓★〓◎☆ Delete the record ☆◎〓★〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓★★★★★★★★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★◎☆ ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★◎☆ 1.According to the student id ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★◎☆ 2.According to the name ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★◎☆ 0.Return to the previous page ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★◎☆ ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★◎☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★★★★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓〓〓〓\n"); printf("\t\n\tPlease enter the corresponding number select the function:"); }}struct node *DelNumber()//按学生学号删除学生信息{ char N[15]; if(u==1) printf("\t请输入要删除的学生的学号:\n\t\t"); else printf("\tPlease enter the student's student id to delete:\n\t\t"); scanf("%s",N); struct node *p1,*p2; p1=p2=head; while(p1!=NULL) { if(strcmp(p1->data.num,N)!=0) { p2=p1; p1=p1->next; } else { if(head==p1) { head=p2=p1->next; free(p1); p1=p2; } else { p2->next=p1->next; free(p1); p1=p2->next; } count--; } } saveflag=1; return head;}struct node *DelName()//按学生姓名删除学生信息{ char M[20]; if(u==1) printf("\t请输入要删除的学生的姓名:\n\t\t"); else printf("\tPlease enter the names of the students to be deleted:\n\t\t"); scanf("%s",M); struct node *p1,*p2; p1=p2=head; while(p1!=NULL) { if(strcmp(p1->data.name,M)!=0) { p2=p1; p1=p1->next; } else { if(head==p1) { head=p2=p1->next; free(p1); p1=p2; } else { p2->next=p1->next; free(p1); p1=p2->next; } count--; } } saveflag=1; return head;}//删除学生信息的主控函数void Del(){ int DelX; system("cls"); DelMenu(); scanf("%d",&DelX); switch(DelX) { case 1: { Disp(DelNumber()); system("pause"); break; } case 2: { Disp(DelName()); system("pause"); break; } case 0:break; default:Wrong();break; } system("pause"); system("cls");}//排序模块菜单void SortMenu(){ system("COLOR 34"); if(u==1) { system("mode con cols=85 lines=30"); printf("\t\t========>>>>>====共有%d个学生记录====>>>>> ^_^\n\n",count); printf("〓〓〓〓〓〓〓〓〓★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓★〓◎☆ 排序菜单 ☆◎〓★〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓★★★★★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓〓★◎☆ ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓〓★◎☆ 1.按学生总分排序 ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓〓★◎☆ 2.按学生C语言成绩排序 ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓〓★◎☆ 3.按学生数学成绩排序 ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓〓★◎☆ 4.按学生英语成绩排序 ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓〓★◎☆ 0.返回上一层 ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓〓★◎☆ ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓〓★◎☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓〓★◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓〓★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓〓〓〓\n"); printf("\t\t\n\t\t请输入相应数字选择该功能:"); } else { system("mode con cols=88 lines=30"); printf("\t========>>>>>====A total of %d student record.====>>>>> ^_^\n\n",count); printf("〓〓〓〓★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓★〓◎☆ Sort Memu ☆◎〓★〓〓〓〓〓〓〓〓\n"); printf("〓〓★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓〓\n"); printf("〓〓〓〓★◎☆ ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓★◎☆ 1.According to the Total sequence ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓★◎☆ 2.According to the C grade sequence ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓★◎☆ 3.According to the Math grade sequence ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓★◎☆ 4.According to the English grade sequence ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓★◎☆ 0.Return on a layer of ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓★◎☆ ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓★◎☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓★◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓〓〓〓\n"); printf("\t\n\tPlease enter the corresponding number select the function:"); }}//按C语言成绩进行排名,返回新链表头节点struct node *RankCgrade(){ struct node *p=head,*q,*l,*r,*h,*w; struct student t; h=w=(struct node*)malloc(LEN);; while(p) { q=(struct node*)malloc(LEN); q->data=p->data; w->next=q; w=w->next; p=p->next; } w->next=NULL; for(q=h->next;q!=NULL;q=q->next) for(l=q->next;l!=NULL;l=l->next) if(l->data.cgrade>q->data.cgrade) { t=q->data; q->data=l->data; l->data=t; } r=h->next; //head=r; return r;}//按数学成绩进行排名,返回新链表头结点struct node *RankMgrade(){ struct node *p=head,*q,*l,*r,*h,*w; struct student t; h=w=(struct node*)malloc(LEN);; while(p) { q=(struct node*)malloc(LEN); q->data=p->data; w->next=q; w=w->next; p=p->next; } w->next=NULL; for(q=h->next;q!=NULL;q=q->next) for(l=q->next;l!=NULL;l=l->next) if(l->data.mgrade>q->data.mgrade) { t=q->data; q->data=l->data; l->data=t; } r=h->next; //head=r; return r;}//按英语成绩进行排名,返回新链表头结点struct node *RankEgrade(){ struct node *p=head,*q,*l,*r,*h,*w; struct student t; h=w=(struct node*)malloc(LEN);; while(p) { q=(struct node*)malloc(LEN); q->data=p->data; w->next=q; w=w->next; p=p->next; } w->next=NULL; for(q=h->next;q!=NULL;q=q->next) for(l=q->next;l!=NULL;l=l->next) if(l->data.egrade>q->data.egrade) { t=q->data; q->data=l->data; l->data=t; } r=h->next; //head=r; return r;}//按总分成绩进行排名,返回新链表头结点struct node *RankTotal(){ struct node *p=head,*q,*l,*r,*h,*w,*lxp; struct student t; h=w=(struct node*)malloc(sizeof(struct node));; while(p) { q=(struct node*)malloc(sizeof(struct node)); q->data=p->data; w->next=q; w=w->next; p=p->next; } w->next=NULL; for(q=h->next;q!=NULL;q=q->next) for(l=q->next;l!=NULL;l=l->next) if(l->data.total>q->data.total) { t=q->data; q->data=l->data; l->data=t; } r=h->next; lxp=r; int i=0; while(lxp!=NULL) { i++; lxp->data.ranking=i; lxp=lxp->next; } //head=r; return r;}//排序功能的主控函数void Sort(){ int SortX,SortX1; system("cls"); SortMenu(); scanf("%d",&SortX); switch(SortX) { case 1: { Disp(RankTotal()); if(u==1) printf("是否按现在的排名保存信息?(1/0)\n\t"); else printf("Whether according to ranking whether save the information according to save the information?(1/0)\n\t"); scanf("%d",&SortX1); if(SortX1==1) head=RankTotal(); if(u==1) printf("信息保存成功!\n\t共有 %d 个学生信息。请按任意键继续……\n",count); else printf("Information saved successfully!\n\tThere are %d students information.Please press any key to continue...\n",count); break; } case 2: { Disp(RankCgrade()); if(u==1) printf("是否按现在的排名保存信息?(1/0)\n\t"); else printf("Whether according to ranking whether save the information according to save the information?\n\t"); scanf("%d",&SortX1); if(SortX1==1) head=RankCgrade(); if(u==1) printf("信息保存成功!\n\t共有 %d 个学生信息。请按任意键继续……\n",count); else printf("Information saved successfully!\n\tThere are %d students information.Please press any key to continue...\n",count); break; } case 3: { Disp(RankMgrade()); if(u==1) printf("是否按现在排名保存信息?(1/0)\n\t"); else printf("Whether according to ranking whether save the information according to save the information?\n\t"); scanf("%d",&SortX1); if(SortX1==1) head=RankMgrade(); if(u==1) printf("信息保存成功!\n\t共有 %d 个学生信息。请按任意键继续……\n",count); else printf("Information saved successfully!\n\tThere are %d students information.Please press any key to continue...\n",count); break; } case 4: { Disp(RankEgrade()); if(u==1) printf("是否按现在排名保存信息?(1/0)\n\t"); else printf("Whether according to ranking whether save the information according to save the information?\n\t"); scanf("%d",&SortX1); if(SortX1==1) head=RankEgrade(); if(u==1) printf("信息保存成功!\n\t共有 %d 个学生信息。请按任意键继续……\n",count); else printf("Information saved successfully!\n\tThere are %d students information.Please press any key to continue...\n",count); break; } case 0:break; default:Wrong();break; } system("pause"); system("cls");}void StatisticsMenu()//统计学生成绩的菜单{ system("COLOR 5C"); if(u==1) { system("mode con cols=83 lines=30"); printf("\t\t========>>>>>====共有%d个学生记录====>>>>> ^_^\n\n",count); printf("〓〓〓〓〓〓〓〓〓★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓★〓◎☆ 统计菜单 ☆◎〓★〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓★★★★★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓〓★◎☆ ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓〓★◎☆ 1.输出C语言第一名信息 ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓〓★◎☆ 2.输出数学第一名信息 ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓〓★◎☆ 3.输出英语第一名信息 ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓〓★◎☆ 4.统计C语言不及格人数 ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓〓★◎☆ 5.统计数学不及格人数 ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓〓★◎☆ 6.统计英语不及格人数 ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓〓★◎☆ 7.输出总分第一名信息 ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓〓★◎☆ 0.返回上一页 ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓〓★◎☆ ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓〓★◎☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓〓★◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓〓〓★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓〓〓〓\n"); printf("\t\t\n\t\t请输入相应数字选择该功能:"); } else { system("mode con cols=127 lines=40"); printf("\t========>>>>>====A total of %d student record.====>>>>> ^_^\n\n",count); printf("〓〓〓〓〓〓★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓★〓◎☆ Statistics Menu ☆◎〓★〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★◎☆ ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★◎☆ 1.Output the student'information who is the first of C ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★◎☆ 2.Output the student'information who is the first of Math ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★◎☆ 3.Output the student'information who is the first of English ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★◎☆ 4.Statistical the amount of who don't pass the C ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★◎☆ 5.Statistical the amount of who don't pass the Math ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★◎☆ 6.Statistical the amount of who don't pass the English ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★◎☆ 7.Output the student'information who is the first of total ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★◎☆ 0.Return on a layer of ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★◎☆ ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★◎☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓〓〓〓\n"); printf("\t\n\tPlease enter the corresponding number select the function:"); }}struct node *StatisticFirstC()//统计学生C语言第一名成绩{ struct node *Cmax,*pt; Cmax=pt=head; while(pt!=NULL) { if(Cmax->data.cgrade <pt->data.cgrade) { Cmax=pt; } pt=pt->next; } return Cmax;}struct node *StatisticFirstE()//统计学生英语第一名成绩{ struct node *Emax,*pt; Emax=pt=head; while(pt!=NULL) { if(Emax->data.egrade <pt->data.egrade) { Emax=pt; } pt=pt->next; } return Emax;}struct node *StatisticFirstM()//统计学生数学第一名成绩{ struct node *Mmax,*pt; Mmax=pt=head; while(pt!=NULL) { if(Mmax->data.mgrade <pt->data.mgrade) { Mmax=pt; } pt=pt->next; } return Mmax;}struct node *StatisticFirstTotal()//统计学生总分成绩第一名{ struct node *Max,*pt; Max=pt=head; while(pt!=NULL) { if(Max->data.total <pt->data.total) { Max=pt; } pt=pt->next; } return Max;}//统计不及格学生,并将各科不及格的学生信息构成新的链表void StatisticsFail(){ struct node *pt; struct node *Cp1,*Cp2; struct node *Ep1,*Ep2; struct node *Mp1,*Mp2; Chead=NULL; Ehead=NULL; Mhead=NULL; Cp1=(struct node *)malloc(LEN); Ep1=(struct node *)malloc(LEN); Mp1=(struct node *)malloc(LEN); Cfail=0,Efail=0,Mfail=0; pt=head; while(pt!=NULL) { if(pt->data.cgrade<60) { Cfail++; Cp1->data=pt->data; if(Cfail==1) Chead=Cp1; else Cp2->next=Cp1; Cp2=Cp1; Cp1=(struct node *)malloc(LEN); Cp1->next=NULL; } if(pt->data.mgrade<60) { Mfail++; Mp1->data=pt->data; if(Mfail==1) Mhead=Mp1; else Mp2->next=Mp1; Mp2=Mp1; Mp1=(struct node *)malloc(LEN); Mp1->next=NULL; } if(pt->data.egrade<60) { Efail++; Ep1->data=pt->data; if(Efail==1) Ehead=Ep1; else Ep2->next=Ep1; Ep2=Ep1; Ep1=(struct node *)malloc(LEN); Ep1->next=NULL; } pt=pt->next; }}void Statistics()//统计学生成绩信息的主控函数{ int StatisticsX; system("cls"); StatisticsMenu(); StatisticsFail(); scanf("%d",&StatisticsX); switch(StatisticsX) { case 1: { Disp(head); printf("该科最高分的学生信息如下:\n"); DispCout(StatisticFirstC()); break; } case 2: { Disp(head); printf("该科最高分的学生信息如下:\n"); DispCout(StatisticFirstM()); break; } case 3: { Disp(head); printf("该科最高分的学生信息如下:\n"); DispCout(StatisticFirstE()); break; } case 4: { system("cls"); //Disp(head); //StatisticsFail(); if(u==1) printf("\n\tC语言课程不及格人数为:%d\n",Cfail); else printf("\nNumber of failed in the C language program to be: %d\n",Cfail); if(u==1) printf("\n\t请按任意键显示C课程不及格的学生信息。\n"); else printf("\n\t请按任意键显示C课程不及格的学生信息。\n"); system("pause"); //Disp(Chead); system("pause"); Disp(Chead); break; } case 5: { system("cls"); //Disp(head); //StatisticsFail(); if(u==1) printf("\n\t数学科不及格人数为:%d\n",Mfail); else printf("\nThe number of failed in the mathematical sciences was: %d\n",Mfail); if(u==1) printf("\n\t请按任意键显示数学不及格的学生信息。\n"); else printf("\n\t请按任意键显示数学不及格的学生信息。\n"); system("pause"); //Disp(Mhead); system("pause"); Disp(Mhead); break; } case 6: { system("cls"); //Disp(head); //StatisticsFail(); if(u==1) printf("\n\t英语科不及格人数为:%d\n",Efail); else printf("\nThe number of failed in the English department was: %d\n",Efail); if(u==1) printf("\n\t请按任意键显示英语不及格的学生信息。\n"); else printf("\n\t请按任意键显示英语不及格的学生信息。\n"); system("pause"); //Disp(Ehead); system("pause"); Disp(Ehead); break; } case 7: { //StatisticsFail(); Disp(head); //printf("总分最高的学生信息如下:\n"); if(u==1) printf("\n\t总分最高者信息如下:\n"); else printf("\n\tThe highest total score information is as follows:\n"); DispCout(StatisticFirstTotal()); break; } case 0:break; default:Wrong();break; } system("pause"); system("cls");}void AddMenu()//添加学生信息的菜单{ system("COLOR 3F"); system("mode con cols=82 lines=30"); if(u==1) { printf("\t\t========>>>>>====共有%d个学生记录====>>>>> ^_^\n\n",count); printf("〓〓〓〓〓★★★★★★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓★★◎☆ 增添学生记录 ☆◎★★〓〓〓〓〓〓〓\n"); printf("〓〓〓★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓\n"); printf("〓〓〓〓〓★◎☆ ☆◎★〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓★◎☆ 1.从文件里增添学生信息 ☆◎★〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓★◎☆ 2.从键盘输入增添学生信息 ☆◎★〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓★◎☆ 0.返回上一页 ☆◎★〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓★◎☆ ☆◎★〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓★◎☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆◎◎★〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓★◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎★〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓★★★★★★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓〓〓\n"); printf("\t\t\n\t\t请输入相应数字选择该功能:"); } else { printf("\t========>>>>>====A total of %d student record.====>>>>> ^_^\n\n",count); printf("〓〓〓〓〓〓★★★★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓★★◎☆ Add the record ☆◎★★〓〓〓〓〓〓〓\n"); printf("〓〓〓〓★★★★★★★★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★◎☆ ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★◎☆ 1.Add student from file ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★◎☆ 2.Add student from keyboard ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★◎☆ 0.Return to the previous page ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★◎☆ ☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★◎☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎★〓〓〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★★★★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓〓〓〓\n"); printf("\t\n\tPlease enter the corresponding number select the function:");}}struct node *AddFile()//从文件读取学生信息{ FILE *fp; struct node *q1,*q2,*lian; int n=0; int xuanze=0; int xuanze1=0; char filename[20]; if(u==1) printf("\t请输入文件名:"); else printf("\tPlease enter the file name:"); while(!scanf("%s",filename)) //接收用户输入的文件名,并对其进行排错 { if(u==1) printf("\tT_T 输入文件名有误,请重新输入: "); else printf("\tT_T Enter the file name is wrong, please input again:"); fflush(stdin); } strcat(filename,".txt"); //count=0; while((fp = fopen(filename,"r")) == NULL) //如果该文件成功打开就进行学生信息的录入,否则继续要求用户输入文件名 { if(u==1) printf("\tT_T 未找到此文件,请重新输入文件名: "); else printf("\tT_T This file is not found, please re-enter the file name: "); scanf("%s",filename); strcat(filename,".txt"); } if(head==NULL) {zheli: count=0; q2=(struct node *)malloc(LEN); fscanf(fp,"%s %s %d %d %d",q2->data.num,q2->data.name,&q2->data.cgrade,&q2->data.mgrade,&q2->data.egrade); q2->data.total=((q2->data.cgrade)+(q2->data.mgrade)+(q2->data.egrade)); q2->data.ave=(q2->data.total/3.0); q2->data.ranking=0; head=q1=q2; count++; while(!feof(fp)) { q2=(struct node *)malloc(LEN); fscanf(fp,"%s %s %d %d %d",q2->data.num,q2->data.name,&q2->data.cgrade,&q2->data.mgrade,&q2->data.egrade); q2->data.total=((q2->data.cgrade)+(q2->data.mgrade)+(q2->data.egrade)); q2->data.ave=(q2->data.total/3.0); q2->data.ranking=0; q1->next=q2; q1=q2; count++; } q1->next=NULL; } else { if(u==1) printf("是否覆盖之前的学生信息?(1.是/0.否)\n\t"); else printf("If information before?(1.YES/0.NO)"); scanf("%d",&xuanze1); if(xuanze1==1) goto zheli; else { struct node *pt; pt=head; while(pt->next!=NULL) {pt=pt->next;} q2=(struct node *)malloc(LEN); fscanf(fp,"%s %s %d %d %d",q2->data.num,q2->data.name,&q2->data.cgrade,&q2->data.mgrade,&q2->data.egrade); q2->data.total=((q2->data.cgrade)+(q2->data.mgrade)+(q2->data.egrade)); q2->data.ave=(q2->data.total/3.0); q2->data.ranking=0; count++; lian=q1=q2; while(!feof(fp)) { q2=(struct node *)malloc(LEN); fscanf(fp,"%s %s %d %d %d",q2->data.num,q2->data.name,&q2->data.cgrade,&q2->data.mgrade,&q2->data.egrade); q2->data.total=((q2->data.cgrade)+(q2->data.mgrade)+(q2->data.egrade)); q2->data.ave=(q2->data.total/3.0); q2->data.ranking=0; q1->next=q2; q1=q2; count++; } q1->next=NULL; pt->next=lian; } } fclose(fp); saveflag=1; printf(" 成功录入学生信息 ^_^\n"); printf(" 学生信息如下: \n"); //RankTotal(); Disp(head); //以表格的形式显示所录入的学生信息 if(u==1) printf("\t是否对信息进行排名?(1/0)"); else printf("\tWhether the information the ranking?(1/0)"); scanf("%d",&xuanze); if(xuanze==1) head=RankTotal(); Disp(head); return head; }void Add()//新建学生信息的主控函数{ int AddX; system("cls"); AddMenu(); scanf("%d",&AddX); switch(AddX) { case 1:{ AddFile(); if(u==1) printf("录入文件信息成功!\n\t共有 %d 个学生信息。请按任意键继续……\n",count); else printf("Input file information successfully!\n\tThere are %d students information.Please press any key to continue...\n",count); system("pause"); break; } case 2:{ system("cls"); AddKeyboard(); if(u==1) printf("录入信息成功!\n\t共有 %d 个学生信息。请按任意键继续……\n",count); else printf("Input information successfully!\n\tThere are %d students information.Please press any key to continue...\n",count); break; } case 0:break; default:Wrong();break; } system("pause"); system("cls");}void InsertMenu()//插入学生信息的菜单{ system("COLOR 71"); if(u==1) { system("mode con cols=82 lines=30"); printf("\t\t========>>>>>====共有%d个学生记录====>>>>> ^_^\n\n",count); printf("〓〓〓〓〓〓〓★★★★★★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★★◎☆ 插入学生记录 ☆◎★★〓〓〓〓〓〓\n"); printf("〓〓〓〓〓★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓★◎☆ ☆◎★〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓★◎☆ 1.插入到某学号后面 ☆◎★〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓★◎☆ 2.插入到某姓名后面 ☆◎★〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓★◎☆ 0.返回上一页 ☆◎★〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓★◎☆ ☆◎★〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓★◎☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆◎◎★〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓★◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎★〓〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓〓★★★★★★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓〓\n"); printf("\t\t\n\t\t请输入相应数字选择该功能:"); } else { system("mode con cols=85 lines=30"); printf("\t========>>>>>====A total of %d student record.====>>>>> ^_^\n\n",count); printf("〓〓〓〓〓〓★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓\n"); printf("〓〓〓〓〓★★◎☆ Insert the record ☆◎★★〓〓〓〓〓\n"); printf("〓〓〓〓★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓\n"); printf("〓〓〓〓〓〓★◎☆ ☆◎★〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★◎☆ 1.Inserted into a student id ☆◎★〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★◎☆ 2.Inserted into one after your name ☆◎★〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★◎☆ 0.Return to the previous page ☆◎★〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★◎☆ ☆◎★〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★◎☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆◎★〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎◎★〓〓〓〓〓〓\n"); printf("〓〓〓〓〓〓★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★〓〓〓〓〓〓\n"); printf("\t\n\tPlease enter the corresponding number select the function:");}}struct node *InsertNumber()//按学生学号插入学生信息{ struct node *newp,*p=NULL; //p=QurNumber(); while(p==NULL) { p=QurNumber(); if(p==NULL) { if(u==1) printf("没有改学号的学生信息,请重新输入学号:\n"); else printf("NO find!"); } } DispCout(p); if(u==1) printf("已找到该学生,请输入插入学生的信息。\n"); else printf("qingjixu.\n"); newp=(struct node *)malloc(LEN); if(newp!=NULL) { if(u==1) printf("\n\n\t请输入学生学号:"); else printf("\n\n Please enter the student student id:"); scanf("%s",newp->data.num); if(u==1) { printf("\n\t请输入学生姓名:"); scanf("%s",newp->data.name); printf("\n\t请输入C课程成绩(0--100):"); scanf("%d",&newp->data.cgrade); printf("\n\t请输入数学课程的成绩(0--100):"); scanf("%d",&newp->data.mgrade); printf("\n\t请输入英语课程的成绩(0--100):"); scanf("%d",&newp->data.egrade); } else { printf("\n Please enter the student's name:"); scanf("%s",newp->data.name); printf("\n Please enter the C language(0--100):"); scanf("%d",&newp->data.cgrade); printf("\n Please enter the mathematics course grades(0--100):"); scanf("%d",&newp->data.mgrade); printf("\n Please enter the English course(0--100):"); scanf("%d",&newp->data.egrade); } newp->data.total=((newp->data.cgrade)+(newp->data.mgrade)+(newp->data.egrade)); newp->data.ave=(newp->data.total/3.0); newp->data.ranking=0; count++; newp->next=p->next; p->next=newp; } else Wrong(); saveflag=1; return head;}struct node *InsertName()//按学生姓名插入学生信息{ struct node *newpn,*pn=NULL; //pn=QurName(); while(pn==NULL) { pn=QurName(); if(pn==NULL) { if(u==1) printf("没有改姓名的学生信息,请重新输入姓名:\n"); else printf("NO find!"); } } DispCout(pn); if(u==1) printf("已找到该学生,请输入插入学生的信息。\n"); else printf("qingjixu.\n"); newpn=(struct node *)malloc(LEN); if(newpn!=NULL) { if(u==1) printf("\n\n\t请输入学生学号:"); else printf("\n\n Please enter the student student id:"); scanf("%s",newpn->data.num); if(u==1) { printf("\n\t请输入学生姓名:"); scanf("%s",newpn->data.name); printf("\n\t请输入C课程成绩(0--100):"); scanf("%d",&newpn->data.cgrade); printf("\n\t请输入数学课程的成绩(0--100):"); scanf("%d",&newpn->data.mgrade); printf("\n\t请输入英语课程的成绩(0--100):"); scanf("%d",&newpn->data.egrade); } else { printf("\n Please enter the student's name:"); scanf("%s",newpn->data.name); printf("\n Please enter the C language(0--100):"); scanf("%d",&newpn->data.cgrade); printf("\n Please enter the mathematics course grades(0--100):"); scanf("%d",&newpn->data.mgrade); printf("\n Please enter the English course(0--100):"); scanf("%d",&newpn->data.egrade); } newpn->data.total=((newpn->data.cgrade)+(newpn->data.mgrade)+(newpn->data.egrade)); newpn->data.ave=(newpn->data.total/3.0); newpn->data.ranking=0; count++; newpn->next=pn->next; pn->next=newpn; } else Wrong(); saveflag=1; return head;}void Insert()//插入学生信息的主控函数{ int InsertX; system("cls"); InsertMenu(); scanf("%d",&InsertX); switch(InsertX) { case 1: { InsertNumber(); RankTotal(); if(u==1) printf("\t插入成功,插入后信息如下:\n"); else printf("\tAfter insert, insert information is as follows:\n"); Disp(head); break; } case 2: { InsertName(); RankTotal(); if(u==1) printf("\t插入成功,插入后信息如下:\n"); else printf("\tAfter insert, insert information is as follows:\n"); Disp(head); break; } case 0:break; default:Wrong();break; } system("pause"); system("cls");}//主函数int main(){ system("COLOR b0"); system("mode con cols=90 lines=30"); //进入系统在C盘打开student.txt文件 FILE *fp; struct node *q1,*q2; int n=0; fp = fopen("C:\\student.txt","ab+"); if(fp==NULL) { printf("\n 不能打开文件!\n"); exit(0); } while(!feof(fp)) { q2=(struct node *)malloc(LEN); fscanf(fp,"%s %s %d %d %d",q2->data.num,q2->data.name,&q2->data.cgrade,&q2->data.mgrade,&q2->data.egrade); q2->data.total=((q2->data.cgrade)+(q2->data.mgrade)+(q2->data.egrade)); q2->data.ave=(q2->data.total/3.0); q2->data.ranking=0; head=q1=q2; count++; while(!feof(fp)) { q2=(struct node *)malloc(LEN); fscanf(fp,"%s %s %d %d %d",q2->data.num,q2->data.name,&q2->data.cgrade,&q2->data.mgrade,&q2->data.egrade); q2->data.total=((q2->data.cgrade)+(q2->data.mgrade)+(q2->data.egrade)); q2->data.ave=(q2->data.total/3.0); q2->data.ranking=0; q1->next=q2; q1=q2; count++; } q1->next=NULL; } fclose(fp); saveflag=1; head=RankTotal();conglai://出错返回标记--满足相应条件时返回到此处 printf(" \t\t========>>>>>=======================>>>>> ^_^\n\n\t\t"); printf("========>>>>>====成功录入学生信息===>>>>> ^_^\n\n\t\t"); printf("========>>>>>=======================>>>>> ^_^\n\n\t\t"); printf("========>>>>>==共有 %d 个学生记录===>>>>> ^_^\n\n\t\t",count); printf("========>>>>>=======================>>>>> ^_^\n\n\t\t"); printf("========>>>>>======O(∩_∩)O~~======>>>>> ^_^\n\n\t\t"); system("pause"); int cun=0; LanguageTips();//系统语言提示 bool quit=false; scanf("%d",&u);//对系统语言进行选择 while(!quit)//进入循环 { system("cls");//清屏 if(u==1 || u==2) ShowMenu(); //显示相应的系统语言菜单 else { Wrong();//错误提示 goto conglai;//出错时返回到标记处 } selectx=-1; //getchar();//让屏幕信息暂留 scanf("%d",&selectx);//对菜单进行选择--选择相应的菜单功能 switch(selectx) { //用户选择0时退出并判断是否存盘,对未存盘信息进行存盘操作 case 0: { while(1) { if(saveflag==1) { if(u==1) printf("数据没有保存,是否保存数据?\n\t1、存盘/0、退出\n\t"); else printf("The data is not saved, save the data?\n\t1.inventory\n\t0.quit\n\t"); scanf("%d",&cun); if(cun==1) Save();//以表格方式存盘 else if(cun==0) break; else Wrong();//错误提示 } else break; } exit(0);//退出系统 } case 1:Add();break; //增加学生信息 case 2:Del();break; //删除学生信息 case 3:Qur();break; //查询学生信息 case 4:Modify();break; //修改学生信息 case 5:Insert();break; //插入学生信息 case 6:Statistics();break; //统计学生信息 case 7:Sort();break; //排序操作 case 8:Save();break; //将学生信息保存到磁盘 case 9:{Disp(head);break;} //将学生信息输出到屏幕 case 10:{system("cls");goto conglai;} //返回上 default:Wrong();break; //给出按键错误的提示 } } return 0;}
有很多地方都有累赘,后面也优化了以下,我觉得尽管很粗糙,但正好见证我的成长,所以把这个没有优化过的放在这里留一个纪念。需要优化的可以给我留言。
1 0
- 学生信息管理系统
- 学生学籍信息管理系统
- 学生信息管理系统
- 学生信息管理系统
- 学生成绩信息管理系统
- 学生信息管理系统
- 【学生信息管理系统 总结】
- 学生信息管理系统--毕业论文
- 学生信息管理系统
- 学生信息管理系统
- 学生信息管理系统~~~~~
- 学生信息管理系统
- 学生信息管理系统总结
- 学生信息管理系统
- 学生信息管理系统
- 学生信息管理系统
- netbeans 学生信息管理系统
- 学生信息管理系统
- 数据库事务四个特性
- mac未能正确推出移动硬盘而读取不了
- MYSQL索引使用
- 调度算法个人研究用
- [Unity3D]单例的一种实现方式
- 学生信息管理系统
- spring之jdbc使用总结
- 初试Unity 3D——常用API(2)
- 算法模式
- java并发(十二)饥饿和公平
- 2016.11.28 C语言环境的搭建
- SPI协议及其工作原理浅析
- JavaScript——Tab选项卡
- 工程管理