1、struct student *FindstudentID(struct student *head,int findID);struct student *FindstudentName(struct student *head,char findname);struct student *InformationInput(struct student *head);void QueryInformation(struct student *head);struct student *EditInformation(struct student *head);struct student *
2、Insert(struct student *head,struct student *p);void Save(struct student *head);struct student *Read(struct student *head);struct student *Delete(struct student *head,int findID);struct student *Add(struct student *head);void Help();/*显示主菜单*/void DispMainMenu() printf(*学生信息管理系统*n);ntttt1-信息录入ntttt2-信
3、息修改ntttt3-信息查询ntttt4-保存数据到文件ntttt5-打开数据文件ntttt6-文件追加ntttt7-帮助ntttt0-退出n友情提示:初次使用请先阅读帮助n*n请选择(0-7):/*显示主菜单*/*帮助*/void Help()nttt欢迎进入帮助系统!nnt1.请按照主菜单提示选择所需执行功能的数字代号!t2.所有文件请按照规范输入nt3.刚开始执行程序时若需要文本文件里的数据,请先进行读取文件信息!t4.修改信息以后,请切记需要保存!/*显示所有学生信息*/void DisplayInformation(struct student *head) struct stude
4、nt *p;*n学号t姓名t年龄t性别t 电话tt地址t 出生年月t emailn p=(struct student *)malloc(LEN); p=head; if(head!=NULL) while(p! printf(%-dt%-st%-dt,p-ID,p-Name,p-age);%-ct%-st%-stxb,p-telephone,p-address);%-d %d %dbirthday.year,p-birthday.month,p-birthday.day);t%-snemail); p=p-next; else printf(无数据n/*查找指定学号的学生信息*/struct
5、 student *FindstudentID(struct student *head,int findID) if(p-ID=findID) break; return p;/*查找指定姓名的学生信息*/struct student *FindstudentName(struct student *head,char findname) if(strcmp(p-Name,findname)=0) else/*学生信息录入*/struct student *InformationInput(struct student *head) int number,i;n请输入本次录入的学生人数: s
6、canf(%d,&number); for(i=0;iID);ttt 姓名:t%sName);ttt 年龄:ttt 性别(男M、女W):xb);ttt 电话(八位):telephone);ttt 地址:ttt 出生年月:%d%d%dbirthday.year,&birthday.month,&tttemail: head=Insert(head,p); p=(struct student *)malloc(LEN); n 您的输入信息是: DisplayInformation(head); return(head);/*学生信息查询*/void QueryInformation(struct
7、student *head) char select; int findID; char findname8;*请选择查询方式*nt1-按学号查询;t2-按姓名查询n*n请选择(1-2):/*显示菜单信息*/ select=getche(); getch(); switch (select) case1:n 按学号查询n 请输入学生的学号: scanf(findID); if(p=FindstudentID(head,findID)!=NULL) /*找到指定学号的学生*/ printf(n 查找结果如下:%dt%st%dt%ct%st%st%d %d %dt%sn else /*没有找到*/
8、您输入的学号不存在!2n 按姓名查询n 请输入学生的姓名:findname); if(p=FindstudentName(head,findname)!=NULL) /*找到指定姓名的学生*/n 学号t 姓名t 年龄t 性别t 电话t 地址t 出生年月t emailn 您输入的姓名不存在! default:选择错误!/*修改学生信息*/struct student *EditInformation(struct student *head)n 请输入学生的学号: if(p=FindstudentID(head,findID)!*请修改方式*nt1-修改信息;t2-删除信息n select=ge
9、tche(); getch(); switch (select) case /*修改信息*/您选择的是修改信息!姓 名:%sn原信息:学号:%dt 年龄:%dt 性别:%cnage,p-t 电话:%st 地址:%stemail:address,p-请输入新信息n学号t scanf(姓名:年龄:性别(男M、女W):电话:地址:出生年月:email: break; /*删除信息*/您选择的是删除信息! head=Delete(head,findID); else /*没有找到学号匹配的记录*/您输入的学号不存在! return (head);/*有序插入*/struct student *Inse
10、rt(struct student *head,struct student *p) struct student *p0,*p1; if(head=NULL) head=p; p-next=NULL; return(head); if(p-IDID)next=head; p1=head; while(p-IDp1-ID)&(p1-next!=NULL) p0=p1; p1=p1-next=p1; p0-next=p; if(p-ID=p1- ; p1- p-/*保存数据到文件*/void Save(struct student *head) FILE *fp; if(fp=fopen(DAT
11、_FILENAME,w+)!=NULL) /*以W+的方式打开文件*/ fprintf(fp,%dt%st %ct%d %d %dt p=p- /*将链表的内容写入文件*/ fclose(fp);cannot open filen/*打开数据文件*/struct student *Read(struct student *head)r /*读取文件中的内容到链表中*/ while(fscanf(fp,ID)!=EOF) fscanf(fp, head=Insert(head,p); p=(struct student *)malloc(LEN); return head;/*文件内容追加*/struct student *Add(struct student *head) head=Read(head); head=InformationInput(head);/*删除信息*/struct student *Delete(struct student *head,int findID) struct student *pre,*p; if(head- p=head; head=head- pre=head; p=pre-=NULL&ID!=findID) pre=p; pre-next=p- free(p);