您好,欢迎访问三七文档
#includestdafx.h#includestdio.h#includestdlib.h#includeconio.h#includemath.h#includestring.h/**********************建立链表******************************/structhj{intage;longnumber;charname[10],address[50],sex[2];structhj*next;};/**************************文件操作函数******************************/FILE*fp;voidopenfile(charxx[20]){fp=fopen(xx,ab+);if(fp==NULL)fp=fopen(xx,wb);}/************************录入信息函数***********************************/voidhjnew(void){system(cls);intn=0,xage;longxnumber;charxname[10];charxaddress[50];charxsex[2];structhj*head;structhj*x1,*x2;head=NULL;x2=NULL;printf(\n★★★★★欢迎使用户籍管理系统★★★★★\n);printf(\n★★★录入信息★★★\n);printf(\n〓提示输入0返回上级菜单〓\n\n\n);printf(\n请输入学号【15字内】:);scanf(%ld,&xnumber);if(xnumber==0)gotohaha;printf(\n请输入姓名【10字内】:);scanf(%s,xname);printf(\n请输入年龄【|-__-|】:);scanf(%d,&xage);printf(\n请输入性别【男OR女】:);scanf(%s,xsex);printf(\n请输入籍贯【25字内】:);scanf(%s,xaddress);while(xnumber!=0){n++;x1=(structhj*)malloc(sizeof(structhj));x1-number=xnumber;strcpy(x1-name,xname);strcpy(x1-sex,xsex);x1-age=xage;strcpy(x1-address,xaddress);if(n==1)head=x1;elsex2-next=x1;x2=x1;printf(\n请输入学号【15字内】:);scanf(%ld,&xnumber);if(xnumber==0)break;printf(\n请输入姓名【10字内】:);scanf(%s,xname);printf(\n请输入年龄【|-__-|】:);scanf(%d,&xage);printf(\n请输入性别【男OR女】:);scanf(%s,xsex);printf(\n请输入籍贯【25字内】:);scanf(%s,xaddress);}x2-next=NULL;x1=head;while(x1!=NULL){openfile(hj.txt);chard[5]=四川;fwrite(x1,sizeof(structhj),1,fp);fclose(fp);if(strstr(x1-address,d)!=NULL){openfile(schj.txt);fwrite(x1,sizeof(structhj),1,fp);fclose(fp);}else{openfile(qthj.txt);fwrite(x1,sizeof(structhj),1,fp);fclose(fp);}x1=x1-next;}haha:;}/*****************************查询函数*************************/voidhjxmselect(void)//按学号方式查询函数{ssmmx:intn=0;longhh;system(cls);printf(\n★★★★★欢迎使用户籍管理系统★★★★★\n);printf(\n★★★查询编辑信息★★★\n);printf(\n〓提示输入0返回上级菜单〓\n\n\n);printf(请您输入学号:);scanf(%ld,&hh);if(hh!=0){structhj*p;structhj*q=NULL,*head=NULL;fp=fopen(hj.txt,rb);if(fp==NULL){printf(\n没有记录,请输入记录然后再查询!);getch();gotojjx;}while(!feof(fp)){n++;p=(structhj*)malloc(sizeof(structhj));fread(p,sizeof(structhj),1,fp);if(n==1)head=p;elseq-next=p;q=p;}q-next=NULL;p=head;while(p!=NULL){if(p-number==hh){inta;printf(\n结果→学号=%ld姓名=%s年龄=%d性别=%s,p-number,p-name,p-age,p-sex);printf(\n地址=%s,p-address);printf(\n\n操作→⑴更改数据⑵删除数据⑶查询其他数据⑷返回上页⑸退出程序\n\n请您选择操作:);ssmx:scanf(%d,&a);switch(a){voidhjedit(structhj*headd,structhj*pp);voidhjdelete(structhj*headdd,structhj*ss);case1:hjedit(head,p);gotossmmx;break;case2:hjdelete(head,p);gotossmmx;break;case3:gotossmmx;case4:gotojjx;case5:exit(0);default:printf(\n错误的选择,请重新选择:);gotossmx;}}elsep=p-next;}intiiii=0;printf(\n没有此记录1.重新查询2.返回上一页3.退出程序!);printf(\n请选择:);qqqq:scanf(%d,&iiii);switch(iiii){case1:gotossmmx;case2:gotojjx;case3:exit(0);default:printf(\n错误的选择,请重新选择:);gotoqqqq;}gotojjx;}jjx:;}voidhjxhselect(void)//按姓名方式查询函数{ssmm:intn=0;charhh[10];system(cls);printf(\n★★★★★欢迎使用户籍管理系统★★★★★\n);printf(\n★★★查询编辑信息★★★\n);printf(\n〓提示输入0返回上级菜单〓\n\n\n);printf(请您输入姓名:);scanf(%s,hh);if(strcmp(hh,0)!=0){structhj*p;structhj*q=NULL,*head=NULL;fp=fopen(hj.txt,rb);if(fp==NULL){printf(\n没有记录,请输入记录然后再查询!);getch();gotojjj;}while(!feof(fp)){n++;p=(structhj*)malloc(sizeof(structhj));fread(p,sizeof(structhj),1,fp);if(n==1)head=p;elseq-next=p;q=p;}q-next=NULL;p=head;while(p!=NULL){if(strcmp(p-name,hh)==0){inta;printf(\n结果→学号=%ld姓名=%s年龄=%d性别=%s,p-number,p-name,p-age,p-sex);printf(\n地址=%s,p-address);printf(\n\n操作→⑴更改数据⑵删除数据⑶查询其他数据⑷返回上页⑸退出程序\n\n请您选择操作:);ssm:scanf(%d,&a);switch(a){voidhjedit(structhj*headd,structhj*pp);voidhjdelete(structhj*headdd,structhj*ss);case1:hjedit(head,p);gotossmm;break;case2:hjdelete(head,p);gotossmm;break;case3:gotossmm;case4:gotojjj;case5:exit(0);default:printf(\n错误的选择,请重新选择:);gotossm;}}elsep=p-next;}intiii=0;printf(\n没有此记录1.重新查询2.返回上一页3.退出程序!);printf(\n请选择:);qqq:scanf(%d,&iii);switch(iii){case1:gotossmm;case2:gotojjj;case3:exit(0);default:printf(\n错误的选择,请重新选择:);gotoqqq;}gotojjj;}jjj:;}voidhjjgselect(void)//按籍贯方式查询{yyy:inti;system(cls);printf(\n★★★★★欢迎使用户籍管理系统★★★★★\n);printf(\n★★★籍贯方式查询信息★★★\n\n\n);printf(\n一显示所有信息\n);printf(\n二显示四川籍所有信息\n);printf(\n三显示其它籍所有信息\n);printf(\n四自定义查询信息\n);printf(\n五←返回上级菜单\n);printf(\n六↓退出程序\n);printf(\n\n请选择:);scanf(%d,&i);switch(i){voidzdyselect(void);voidallselect(chara[8]);case1:allselect(hj.txt);gotoyyy;break;case2:allselect(schj.txt);gotoyyy;break;case3:allselect(qthj.txt);gotoyyy;break;case4:zdyselect();case5:break;case6:exit(0);}}voidzdyselect(void){ssmmz:intn=0,j=0;charhh[10];system(cls);printf(\n★★★★★欢迎使用户籍管理系统★★★★★\n);printf(\n★★★自定义查询信息★★★\n\n\n);printf(请您输入地址关键字:);scanf(%s,hh);if(strcmp(hh,0)!=0){structhj*p;structhj*q=NULL,*head=NULL;fp=fopen(hj.txt,rb);if(fp==NULL){printf(\n没有记录,请输入记录然后再查询!);getch();gotojjz;}while(!feof(fp)){n++;p=(structhj*)malloc(sizeof(structhj));fread(p,sizeof(structhj),1,fp);if(n==1)head=p;elseq-next=p;q=p;}q-next=NULL;p=head;while(p!=NULL){if(strstr(p-address,hh)!=NULL){inta;j++;printf(\n结果→学号=%ld姓名=%s年龄=%d性别=%s,p-number,p-name,p-age,p-sex);printf(\n地址=%s,p-address);printf
本文标题:学生籍贯管理系统
链接地址:https://www.777doc.com/doc-3958142 .html