#includestdio.h#includedos.h#defineNsizeof(structSTH)#defineGESHI%-10ld%-10s%-5s%-4d/%-2d/%-4d%-12s%-12s%s\n#definePRINTF学号姓名性别生日系别班级家庭住址\nstructSTH*readfile();/*声明*/intinsert(structSTH**);intn=0;structdt{intyear;/*全局变量*/intmonth;intday;};structSTH{longnum;/*学号不能以0开头*/charname[9];charsex[5];structdtbirth;charxi[20];charban[20];charadd[30];structSTH*next;}*head;/*输入模块*/input_message(){charch;intflag=1;do{if(insert(&head)!=0)n++;/*计数*/elseprintf(\n有相同的的学号!);printf(\n是否继续?(y/n));getchar();scanf(%c,&ch);if(ch=='y'||ch=='Y'){printf(\n继续!);getch();flag=1;/*标志程序不结束*/}elseflag=0;}while(flag==1);save_message();printf(按任意键继续...);getch();}/*insert()模块*//*被输入和插入模块所调用*/intinsert(structSTH**h){structSTH*p,*p0;p=(structSTH*)malloc(N);printf(\n请输入学号:);scanf(%ld,&p-num);printf(\n请输入姓名:);scanf(%s,p-name);printf(\n请输入性别:);getchar();/*取走上一个留下来得‘\n’*/scanf(%s,p-sex);printf(\n请输入生日(年月日,用回车隔开):\n);scanf(%d%d%d,&p-birth.year,&p-birth.month,&p-birth.day);printf(\n请输入系别:);scanf(%s,p-xi);printf(\n请输入班级:);scanf(%s,p-ban);printf(\n请输入家庭住址:);scanf(%s,p-add);p-next=NULL;if(*h==NULL){*h=p;return1;}p0=*h;if(p0-nump-num){p-next=p0;*h=p;return1;}while(p0-next!=NULL&&p0-next-nump-num)p0=p0-next;if(p0-next==NULL){p0-next=p;return1;}elseif(p0-next-num==p-num){free(p);/*有相同数据输入失败*/return0;}else{p-next=p0-next;p0-next=p;return1;}}/*读文件模块*//*读文件模块中创建了一个新的链表,其返回值为新链表的头指针*/structSTH*readfile(){FILE*fp;structSTH*p,*p0;charch;inti;if((fp=fopen(STH.txt,r))==NULL){printf(\n不能读取文件!\n);returnNULL;}/*注意要该*/head=p=p0=(structSTH*)malloc(N);fscanf(fp,%d,&n);fscanf(fp,%c,&ch);/*为了使学号和信息个数分开加入一个‘/’*/fscanf(fp,%ld%s%s%d%d%d%s%s%s,&p-num,p-name,p-sex,&p-birth.year,&p-birth.month,&p-birth.day,p-xi,p-ban,p-add);p-next=NULL;i=1;/*如果只有一个数时跳出*/if(n!=1){do{p=(structSTH*)malloc(N);fscanf(fp,%ld%s%s%d%d%d%s%s%s,&p-num,p-name,p-sex,&p-birth.year,&p-birth.month,&p-birth.day,p-xi,p-ban,p-add);p0-next=p;p0=p;i++;}while(in);p0-next=NULL;}fclose(fp);returnhead;}/*插入模块*/insert_message(){structSTH*p;intflag=1;charch;head=readfile();do{if(insert(&head)!=0){n++;save_message();printf();}/*计数*/else{printf(\n添加失败!\n有相同的的学号!);save_message();getch();}printf(\n是否继续?(y/n));getchar();ch=getchar();if(ch=='y'||ch=='Y'){printf(\n继续!);flag=1;/*标志程序不结束*/}elseflag=0;}while(flag==1);printf(\n按任意键继续...);getch();}/*修改模块*/renew_message(){structSTH*p;inti,flag=1;longnum;p=head=readfile();if(head==NULL){printf(读文件有误!);getch();}else{printf(\n请按输入要修改的学生的学号:);scanf(%ld,&num);for(i=0;in;i++){if(p-num==num){p-num=num;printf(\n已找到要%ld号学生的信息!\n,num);printf(原姓名为%s要修改为:\n,p-name);scanf(%s,p-name);printf(原性别为%s要修改为:\n,p-sex);scanf(%s,p-sex);printf(原生日为%d/%d/%d要修改为:\n,p-birth.year,p-birth.month,p-birth.day);scanf(%d%d%d,&p-birth.year,&p-birth.month,&p-birth.day);printf(原系别为%s要修改为:\n,p-xi);scanf(%s,p-xi);printf(原班级为%s要修改为:\n,p-ban);scanf(%s,p-ban);printf(原家庭住址为%s要修改为:\n,p-add);scanf(%s,p-add);printf(你所更改后的信息为:\n);printf(PRINTF);printf(GESHI,p-num,p-name,p-sex,p-birth.year,p-birth.month,p-birth.day,p-xi,p-ban,p-add);printf(\n按任意键退出!\n);getch();flag=1;break;}elsep=p-next;}if(flag!=1)printf(无此人信息!\n);elsesave_message();getch();}}/*删除模块*/delete_message(){intflag;longnum;charch;structSTH*p,*p0;p0=p=head=readfile();if(head==NULL){printf(文件读取出错!);getch();}else{printf(请输入要删除学生的学号:\n);scanf(%ld,&num);if(p0-num==num){head=p0-next;free(p0);flag=1;n--;/*学生数减一*/}p=p0-next;while(p!=NULL){if(p-num==num){p0-next=p-next;free(p);flag=1;n--;}else{p0=p;p=p-next;}}if(p-next==NULL)flag=0;if(flag==1){printf(\n永久删除%ld号学生的信息?(y/n),num);getchar();ch=getchar();if(ch=='y'||ch=='Y')save_message();else{printf(\n撤消删除!);getch();}}elseprintf(\n删除失败!);getch();}}/*查询模块*/inquire_message(){inti,flag=0;longnum;structSTH*p;p=head=readfile();if(head==NULL){printf(文件读取出错!);getch();}else{printf(请输入要查询学生的学号:\n);scanf(%ld,&num);for(i=0;in;i++){if(p-num==num){printf(\n信息已找到:\n);getch();clrscr();printf(**********************************FOUND*********************************\n);printf(------------------------------------------------------------------------\n\n);printf(PRINTF);printf(GESHI,p-num,p-name,p-sex,p-birth.year,p-birth.month,p-birth.day,p-xi,p-ban,p-add);printf(\n------------------------------------------------------------------------\n);printf(***********************************END**********************************\n);flag=1;break;}elsep=p-next;}if(flag==0)printf(\n无此人信息!);elseprintf(\n显示完毕!\按任意键返回主菜单......);getch();}}/*显示模块*/output_message(){inti=0;structSTH*p;p=head=readfile();if(head==NULL){printf(文件读取出错!);getch();}else{clrscr();printf(\n************************************STUDENT************************************\n);printf(-------------------------------------------------------------------------------\n);printf(PRINTF);while(in){printf(GESHI,p-num,p-name,p-sex,p-birth.year,p-birth.month,p-birth.day,p-xi,p-ban,p-add);p=p-next;i++;}printf(-------------------------------------------------------------------------------\n);printf(*****