版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、#include stdafx.h#include stdio.h#include stdlib.h#include conio.h#include math.h#include string.h /*建立链表*/struct hj int age;long number;char name10,address50,sex2;struct hj *next;/*文件操作函数*/FILE *fp;void openfile(char xx20)fp=fopen(xx,ab+);if(fp=NULL)fp=fopen(xx,wb);/*录入信息函数*/void hjnew(void) system
2、(cls);int n=0,xage;long xnumber;char xname10;char xaddress50;char xsex2;struct hj *head;struct hj *x1,*x2;head=NULL;x2=NULL;printf(n 欢迎使用户籍管理系统n);printf(n 录入信息n);printf(n 提示输入0返回上级菜单nnn);printf(n 请输入学号【15字内】:);scanf(%ld,&xnumber);if(xnumber=0)goto haha;printf(n 请输入姓名【10字内】:);scanf(%s,xname);printf(n
3、 请输入年龄【|-_-|】:);scanf(%d,&xage);printf(n 请输入性别【男OR女】:); scanf(%s,xsex);printf(n 请输入籍贯【25字内】:);scanf(%s,xaddress); while(xnumber!=0)n+;x1=(struct hj *)malloc(sizeof(struct hj);x1-number=xnumber; strcpy(x1-name,xname);strcpy(x1-sex,xsex);x1-age=xage;strcpy(x1-address,xaddress);if(n=1)head=x1;elsex2-ne
4、xt=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); char d5=四川
5、; fwrite(x1,sizeof(struct hj),1,fp); fclose(fp); if(strstr(x1-address,d)!=NULL)openfile(schj.txt); fwrite(x1,sizeof(struct hj),1,fp); fclose(fp); elseopenfile(qthj.txt); fwrite(x1,sizeof(struct hj),1,fp); fclose(fp); x1=x1-next; haha:;/*查询函数*/void hjxmselect(void) /按学号方式查询函数ssmmx: int n=0; long hh;
6、system(cls); printf(n 欢迎使用户籍管理系统n); printf(n 查询编辑信息n); printf(n 提示输入0返回上级菜单nnn); printf( 请您输入学号:); scanf(%ld,&hh); if(hh!=0) struct hj *p; struct hj *q=NULL,*head=NULL; fp=fopen(hj.txt,rb); if(fp=NULL)printf(n没有记录,请输入记录然后再查询!); getch(); goto jjx; while(!feof(fp)n+; p=(struct hj *)malloc(sizeof(struc
7、t hj); fread(p,sizeof(struct hj),1,fp); if(n=1) head=p; else q-next=p; q=p; q-next=NULL; p=head; while(p!=NULL)if(p-number=hh)int a; printf(n 结 果 学号=%ld 姓名=%s 年龄=%d 性别=%s ,p-number,p-name,p-age,p-sex); printf(n 地址=%s,p-address); printf(nn 操 作 更改数据 删除数据 查询其他数据 返回上页 退出程序nn 请您选择操作:); ssmx: scanf(%d,&a)
8、; switch(a)void hjedit(struct hj *headd,struct hj *pp); void hjdelete(struct hj *headdd,struct hj *ss); case 1: hjedit(head,p); goto ssmmx;break; case 2: hjdelete(head,p); goto ssmmx;break; case 3: goto ssmmx; case 4: goto jjx; case 5:exit(0); default:printf(n 错误的选择,请重新选择:); goto ssmx; else p=p-next
9、; int iiii=0; printf(n 没有此记录 1.重新查询 2.返回上一页 3.退出程序!); printf(n 请选择:); qqqq: scanf(%d,&iiii); switch(iiii)case 1: goto ssmmx;case 2: goto jjx;case 3: exit(0);default: printf(n 错误的选择,请重新选择:);goto qqqq; goto jjx; jjx:;void hjxhselect(void)/按姓名方式查询函数ssmm:int n=0;char hh10;system(cls);printf(n 欢迎使用户籍管理系统
10、n);printf(n 查询编辑信息n);printf(n 提示输入0返回上级菜单nnn);printf( 请您输入姓名:);scanf(%s,hh);if(strcmp(hh,0)!=0)struct hj *p; struct hj *q=NULL,*head=NULL; fp=fopen(hj.txt,rb); if(fp=NULL)printf(n没有记录,请输入记录然后再查询!); getch(); goto jjj; while(!feof(fp)n+;p=(struct hj *)malloc(sizeof(struct hj);fread(p,sizeof(struct hj)
11、,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)int a; printf(n 结 果 学号=%ld 姓名=%s 年龄=%d 性别=%s ,p-number,p-name,p-age,p-sex); printf(n 地址=%s,p-address); printf(nn 操 作 更改数据 删除数据 查询其他数据 返回上页 退出程序nn 请您选择操作:); ssm: scanf(%d,&a); switch(a) void hjedit(struc
12、t hj *headd,struct hj *pp);void hjdelete(struct hj *headdd,struct hj *ss);case 1: hjedit(head,p);goto ssmm;break;case 2: hjdelete(head,p);goto ssmm;break;case 3: goto ssmm;case 4: goto jjj;case 5:exit(0);default:printf(n 错误的选择,请重新选择:);goto ssm; else p=p-next; int iii=0; printf(n 没有此记录 1.重新查询 2.返回上一页
13、 3.退出程序!); printf(n 请选择:); qqq: scanf(%d,&iii); switch(iii)case 1: goto ssmm;case 2: goto jjj;case 3: exit(0);default: printf(n 错误的选择,请重新选择:);goto qqq; goto jjj; jjj: ;void hjjgselect(void)/按籍贯方式查询yyy: int i; system(cls); printf(n 欢迎使用户籍管理系统n); printf(n 籍贯方式查询信息nnn); printf(n 一 显示所有信息n); printf(n 二
14、显示四川籍所有信息n); printf(n 三 显示其它籍所有信息n); printf(n 四 自定义查询信息n); printf(n 五 返回上级菜单n); printf(n 六 退出程序n); printf(nn 请选择:); scanf(%d,&i); switch(i)void zdyselect(void);void allselect(char a8);case 1:allselect(hj.txt);goto yyy;break;case 2: allselect(schj.txt);goto yyy;break;case 3: allselect(qthj.txt);goto
15、yyy;break;case 4: zdyselect();case 5: break;case 6: exit(0);void zdyselect(void) ssmmz:int n=0,j=0;char hh10;system(cls);printf(n 欢迎使用户籍管理系统n);printf(n 自定义查询信息nnn); printf( 请您输入地址关键字:); scanf(%s,hh); if(strcmp(hh,0)!=0) struct hj *p;struct hj *q=NULL,*head=NULL;fp=fopen(hj.txt,rb);if(fp=NULL)printf(
16、n 没有记录,请输入记录然后再查询!);getch();goto jjz; while(!feof(fp)n+;p=(struct hj *)malloc(sizeof(struct hj);fread(p,sizeof(struct hj),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) int a;j+;printf(n 结 果 学号=%ld 姓名=%s 年龄=%d 性别=%s ,p-number,p-name,p-age,p-se
17、x); printf(n 地址=%s,p-address);printf(nn 操 作 更改数据 删除数据 查询下一条数据 返回上页 退出程序nn 请您选择操作:);ssmz:scanf(%d,&a);switch(a) void hjedit(struct hj *headd,struct hj *pp);void hjdelete(struct hj *headdd,struct hj *ss);case 1: hjedit(head,p);goto ssmmz;break;case 2: hjdelete(head,p);goto ssmmz;break;case 3: p=p-next
18、;continue;case 4: goto jjz;case 5:exit(0);default:printf(n 错误的选择,请重新选择:);goto ssmz; p=p-next; elsep=p-next; if(j=0)printf(nnn没有匹配的记录 按任意键继续!);getch();fclose(fp);goto ssmmz; elseint xx;printf(nn查询完毕! 继续查询 返回上一级菜单 退出程序);printf(n请选择:);scanf(%d,&xx);if(xx=2)goto jjz;else if(xx=3)exit(0); goto ssmmz; jjz
19、: ; void allselect(char a8)/全部查询int n=0;int k=0;system(cls);printf(n 欢迎使用户籍管理系统n);printf(n 籍贯方式信息nnn); struct hj *p;struct hj *q=NULL,*head=NULL;fp=fopen(a,rb);if(fp=NULL)printf(n对不起,没有记录无法查询!);goto xxxx;rewind(fp);while(!feof(fp)n+;p=(struct hj *)malloc(sizeof(struct hj);fread(p,sizeof(struct hj),1
20、,fp);if(n=1)head=p;elseq-next=p;q=p;q-next=NULL; struct hj *h1,*p2,*q3,*r4,*s5;h1=p2=(hj *)malloc(sizeof(struct hj);p2-next=head;while(p2-next!=NULL) q3=p2-next; r4=p2; while(q3-next!=NULL) if(q3-next-numbernext-number) r4=q3; q3=q3-next; if(r4!=p2) s5=r4-next; r4-next=s5-next; s5-next=p2-next; p2-n
21、ext=s5; p2=p2-next; head=h1-next-next; free(h1); p=head;while(p!=NULL&n0)n-;printf(n学号=%ld 姓名=%s 年龄=%d 性别=%s ,p-number,p-name,p-age,p-sex);printf(n地址=%s,p-address); p=p-next;xxxx:printf(n显示完毕n 返回上级菜单 退出程序 n请 选 择 :);xxx:scanf(%d,&n);switch(n)case 1:break;case 2:exit(0);default:printf(n错误的选择,请重新选择:);g
22、oto xxx;void hjselect(void)/查询编辑信息函数 cxbegin:int a;system(cls);printf(n 欢迎使用户籍管理系统n);printf(n 查询编辑信息nnn);printf(n 一 按学号方式查询n);printf(n 二 按姓名方式查询n);printf(n 三 按籍贯方式查询n);printf(n 四 显示全部信息n);printf(n 五 返回上级菜单n);printf(n 请 选 择 查 询 方 式:);cxmm:scanf(%d,&a);switch(a) case 1: hjxmselect();goto cxbegin;break
23、;case 2: hjxhselect();goto cxbegin;break;case 3: hjjgselect();goto cxbegin;break;case 4: allselect(hj.txt);goto cxbegin;break;case 5: break;default:printf(n错误的选择,请重新选择:); goto cxmm;void hjde(void)/删除界面函数cxxbegin:int a;system(cls);printf(n 欢迎使用户籍管理系统n);printf(n 删除信息nnn);printf(n 一 按学号方式删除n);printf(n
24、二 按姓名方式删除n);printf(n 三 按籍贯方式删除n);printf(n 四 删除全部信息n);printf(n 五 返回上级菜单n);printf(n 请 选 择 删 除 方 式:);cxxmm:scanf(%d,&a);int i=0;switch(a) case 1: hjxmselect();goto cxxbegin;break;case 2: hjxhselect();goto cxxbegin;break;case 3: zdyselect();goto cxxbegin;break;case 4: fp=fopen(hj.txt,wb);if(fp!=NULL)i+;
25、fp=fopen(schj.txt,wb);if(fp!=NULL)i+;fp=fopen(qthj.txt,wb);if(fp!=NULL)i+;if(i=3)printf(n 全部数据已经删除!敲任意键继续);getch();goto cxxbegin;break;case 5: break;default:printf(n错误的选择,请重新选择:);goto cxxmm;/=删除函数接口=void hjdelete(struct hj *headdd,struct hj *ss)struct hj *q;char d5=四川;if(headdd=ss)headdd=headdd-next
26、;goto gogo;q=headdd;while(q!=NULL)if(q-next-number=ss-number) break;q=q-next; q-next=ss-next;gogo:q=headdd; fp=fopen(hj.txt,wb);while(q!=NULL)fwrite(q,sizeof(struct hj),1,fp);q=q-next;fclose(fp);q=headdd;fp=fopen(schj.txt,wb);while(q!=NULL) if(strstr(q-address,d)!=NULL) fwrite(q,sizeof(struct hj),1,fp);q=q-next;fclose(fp);q=headdd;fp=fopen(qthj.txt,wb);while(q!=NULL) if(strstr(q-address,d)=NULL) fwrite(q,sizeof(struct hj),1,fp);q=q-next;fclose(fp);/=编辑函数接口=void hjedit(struct hj *headd,struct hj *pp)int n=0;struct hj *p,*p1,*p2;char d5=四川;prin
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 汽车电焊工试题及答案
- 湖南省永州市祁阳市2024-2025学年八年级上学期期末质量检测地理试卷(含答案)
- 《GAT 705-2007公安警卫基础工作信息数据结构》专题研究报告
- 《GAT 543.16-2018公安数据元(16)》专题研究报告深度
- 《GAT 16.43-2012道路交通管理信息代码 第43部分:交通事故形态分类与代码》专题研究报告
- 2026年深圳中考物理大气压强专项试卷(附答案可下载)
- 定日镜题目及答案
- 2026年大学大二(计算机科学与技术)数据库原理应用综合测试题及答案
- 2026年深圳中考数学考前3天预测试卷(附答案可下载)
- 2026年人教版物理九年级下册期中质量检测卷(附答案解析)
- 5年级下册英语人教版单词表
- 腊味宣传课件及教案
- 2025-2030中国压缩饼干市场销售渠道与未来竞争力优势分析报告
- T/CCPITCSC 120-2023中国品牌影响力评价通则
- 医学检验免疫课件
- 农村土地永久性转让合同
- 中建市政道路施工组织设计方案
- 财务先进个人代表演讲稿
- DB23T 2689-2020养老机构院内感染预防控制规范
- 2025届天津市和平区名校高三最后一模语文试题含解析
- 建筑施工现场污水处理措施方案
评论
0/150
提交评论