




已阅读5页,还剩14页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
#include #include #include #include struct stuTypecharname9;/姓名chargender3;/性别intage;/年龄charphone11;/手机号 intstature;/身高stud100; /;不可少/*/void GotoXY(int x, int y);void shuru();void zhuye();void chaxun();void chaxunsx();void chaxun_name();void chaxunlb();void chaxunxm1();void chaxunxm2();void displist();void change();void sort();void sort_age();void sort_stature();void statistics();/*/void main()/主函数 zhuye();/系统首页/*/void GotoXY(int x, int y)/坐标定位函数COORD c;c.X = x - 1;c.Y = y - 1;SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), c);/*控制输入的函数*/void shuru() int gdok;int nmOk;int ageok;int stok; char keypress; FILE *fp;if(fp=fopen(stuType, a)=NULL) printf(cannot open filen);return; GotoXY(30,3);printf(请顺序输入各项信息);GotoXY(5,4);printf(=);GotoXY(5,6);printf(姓名: 性别: 年龄: 手机号码: 身高(cm): );for(int i=0; i100|studi.age230|studi.stature50)GotoXY(10,9);printf(身高必须为50到230的数,按任意键继续.);getche();GotoXY(10,9);printf( );elsestok=true; if(fwrite(&studi, sizeof(struct stuType), 1, fp)!=1) printf(file write errorn); fclose(fp); GotoXY(10,9); printf(是否继续添加信息(Y/N);scanf(%s,&keypress); if(keypress=N|keypress=n) system(cls); zhuye();else if(keypress=Y|keypress=y) system(cls); shuru();elseexit(0); void zhuye()int select;GotoXY(30,3); printf(同学通信录管理系统);GotoXY(15,4);printf(=); GotoXY(15,6); printf(1:输入); GotoXY(35,6); printf(2:查询); GotoXY(55,6); printf(3:修改); GotoXY(15,10); printf(4:排序); GotoXY(35,10); printf(5:统计); GotoXY(55,10); printf(0:退出); GotoXY(15,12);printf(=);GotoXY(15,14);printf(请输入要查询的选项:);select=getch(); if(select53) printf(请输入0到5选项);else switch(select)case 49:/1:输入 system(cls);shuru();break;case 50:/2:查询system(cls);chaxun();break; case 51:/3:修改system(cls);change();break; case 52:/4:排序 system(cls); sort(); break; case 53:/5:统计system(cls); statistics(); break; case 48:/0:退出exit(0);break; void chaxun()int selectcx;int prX=5;int prY=5;GotoXY(prX,prY+2);printf(1.顺序查询);GotoXY(prX,prY+4);printf(2.按姓名查询);GotoXY(prX,prY+6);printf(3.列表查询);GotoXY(prX,prY+8);printf(0.结束查询);GotoXY(prX,prY+10);printf(请选择您要查询的方式:);selectcx=getch();if(selectcx51)printf(请输入0到3选项);else switch(selectcx) case 48:/0:结束查询 system(cls);zhuye();break;case 49:/1:顺序查询 system(cls);chaxunsx();break;case 50:/2:姓名查询 system(cls);chaxun_name();break; case 51:/3:列表查询 system(cls); displist();break;void chaxunsx()printf(以下为您查询的信息(顺序查询);int i=0;char key1;FILE *fp;if(fp=fopen(stuType, r)=NULL)printf(can not open filen); return;while(!feof(fp) fread(&studi, sizeof(struct stuType), 1, fp);GotoXY(10,3);printf(姓 名 性别 年龄 手 机 身高(CM)); GotoXY(10,5);printf(%s %s %s %s %d %s %s %s %dn,, ,studi.gender, , studi.age, , studi.phone, ,studi.stature);GotoXY(10,7); printf(%s %d %s,当前是第,i+1,条记录);GotoXY(10,9);printf(是否继续查询(Y/N):); if(feof(fp) system(cls); printf(结束查询,输入N返回上一层,按任意键关闭窗口:);scanf(%s,&key1);if(key1=y|key1=Y) system(cls);i=i+1;if(key1=N|key1=n)system(cls);chaxun(); fclose(fp);void chaxun_name()printf(nn%s, 1:精确查询);printf(nn%s, 2:模糊查询);printf(nn%s, 0:返回);printf(nn%s,请输入您要查询的方式:);int selectxm;selectxm=getch();if(selectxm50)printf(请输入0到2选项);else switch(selectxm) case 48:/0:结束查询 system(cls);chaxun();break;case 49:/1:全称查询 system(cls);chaxunxm1();break;case 50:/2:模糊查询 system(cls);chaxunxm2();break;void chaxunxm1() char search9; char key2; FILE *fp; printf(请输入您要查询的姓名:); if(fp=fopen(stuType, r)=NULL) printf(can not open filen); return; scanf(%s,&search); GotoXY(1,3); printf(姓 名 性别 年龄 手 机 身高(CM)); GotoXY(1,5);printf(=);for(int i=0;i100&!feof(fp);i+) fread(&studi, sizeof(struct stuType), 1, fp); if(strcmp(search,)=0) printf(nn%s %s %s %s %d %s %s %s %dn,, ,studi.gender, , studi.age, , studi.phone, ,studi.stature); printf(n%s,是否继续查询(Y/N):); scanf(%s,&key2);if(key2=y|key2=Y) system(cls);chaxunxm1();if(key2=N|key2=n)system(cls);chaxun_name();void chaxunxm2() char search9; char key2; FILE *fp; printf(请输入您要查询的字段:); if(fp=fopen(stuType, r)=NULL) printf(can not open filen); return; scanf(%s,&search); GotoXY(1,3);printf(姓 名 性别 年龄 手 机 身高(CM)); GotoXY(1,5);printf(=);for(int i=0;i100&!feof(fp);i+) fread(&studi, sizeof(struct stuType), 1, fp); char *str1 = , *str2 = search, *ptr; if(ptr = strstr(str1, str2) printf(nn%s %s %s %s %d %s %s %s %dn,, ,studi.gender, , studi.age, , studi.phone, ,studi.stature); printf(n%s,是否继续查询(Y/N):); scanf(%s,&key2);if(key2=y|key2=Y) system(cls);chaxunxm2();if(key2=N|key2=n)system(cls);chaxun_name(); void displist() int pagelen = 20;/一页显示的记录数int cntInPage; int count;int i = 0; FILE *fp; if(fp=fopen(stuType, r)=NULL) printf(can not open filen); return;for(int k=0; k100& !feof(fp); k+) fread(&studk, sizeof(struct stuType), 1, fp); count=k-1; fclose(fp); while(i count)system(cls);GotoXY(10, 1);printf(共有 %d 位同学,每页显示 %d 个记录, count, pagelen);GotoXY(10, 2);printf(=);GotoXY(10, 3);printf( 姓名 性别 年龄 手机 身高);cntInPage = 1;while(icount & cntInPage=pagelen) fread(&studi, sizeof(struct stuType), 1, fp);GotoXY(10, 4+cntInPage); printf(%s, ); GotoXY(25, 4+cntInPage);printf(%s %d %s %d, studi.gender,studi.age,studi.phone,studi.stature); cntInPage+;i+;GotoXY(10, 24);printf(=);GotoXY(10, 25);if(i count)printf(按任意键继续显示下一页.);elseprintf(查询结束,按任意键退出);getch();void change() int count; FILE *fp; if(fp=fopen(stuType, r)=NULL) printf(can not open filen); return;for(int t=0; t100& !feof(fp); t+) fread(&studt, sizeof(struct stuType), 1, fp); count=t-1; fclose(fp);printf(先查询到您要修改的信息:); char search9; printf(请输入您要查询的字段:); if(fp=fopen(stuType, r)=NULL) printf(can not open filen); return; scanf(%s,&search); GotoXY(1,3);printf(姓 名 性别 年龄 手 机 身高(CM)); GotoXY(1,5);printf(=);for(int i=0;i100&!feof(fp);i+) fread(&studi, sizeof(struct stuType), 1, fp); char *str1 = , *str2 = search, *ptr; if(ptr = strstr(str1, str2) printf(nn%s %s %s %s %d %s %s %s %d 第%d个记录,, ,studi.gender, , studi.age, , studi.phone, ,studi.stature,i); printf(nn%s,选择要修改的记录的编号:);scanf(%d,&i); fread(&studi, sizeof(struct stuType), 1, fp);system(cls);GotoXY(5,3); printf(%s %s %s %s %d %s %s %s %d,, ,studi.gender, , studi.age, , studi.phone, ,studi.stature); GotoXY(10,5);printf(请输入您要修改为的信息,);GotoXY(10,7);printf(=); GotoXY(10,9);printf(姓名:); GotoXY(10,11); printf(性别:); GotoXY(10,13); printf(年龄:); GotoXY(10,15); printf(手机:); GotoXY(10,17); printf(身高:);GotoXY(10,19); printf(=);GotoXY(10,20);printf(以下为您修改后的信息);GotoXY(15,9);scanf(%s,); GotoXY(15,11);scanf(%s,&studi.gender); GotoXY(15,13); scanf(%d,&studi.age); GotoXY(15,15);scanf(%s,studi.phone); GotoXY(15,17); scanf(%d,&studi.stature); if(fp=fopen(stuType, w)=NULL) printf(can not open filen); return; for(int k=0;kcount;k+) if(fwrite(&studk, sizeof(struct stuType), 1, fp)!=1) printf(file write errorn); fclose(fp); GotoXY(5,21); printf(%s %s %s %s %d %s %s %s %dn,, ,studi.gender, , studi.age, , studi.phone, ,studi.stature); char key2; GotoXY(5,23); printf(是否继续修改(N/Y); key2=getche();if(key2=y|key2=Y) system(cls);change();if(key2=N|key2=n)system(cls);zhuye();void sort() int selectsort;GotoXY(10,7);printf(1:按年龄排列);GotoXY(10,9);printf(2:按身高排列);GotoXY(10,5);printf(请选择您要排列的方式(按0返回):);selectsort=getch();switch(selectsort)case 49:/1:年龄排序 system(cls); sort_age();break;case 50:/2:身高排序system(cls); sort_stature();break; case 48:/0:返回system(cls);zhuye();break; void sort_age() int pagelen = 20;/一页显示的记录数int cntInPage; int count;int i = 0; FILE *fp; if(fp=fopen(stuType, r)=NULL) printf(can not open filen); return;for(int k=0; k100& !feof(fp); k+) fread(&studk, sizeof(struct stuType), 1, fp); count=k-1; fclose(fp); while(i count)system(cls);GotoXY(10, 1);printf(共有 %d 位同学,每页显示 %d 个记录, count, pagelen);GotoXY(10, 2);printf(=);GotoXY(10, 3);printf( 姓名 性别 年龄 手机 身高);cntInPage = 1;while(icount & cntInPage=0)for(int i=0;istudi+1.age)a=studi+1;studi+1=studi;studi=a;count_age-;/*/GotoXY(10, 4+cntInPage); printf(%s, ); GotoXY(25, 4+cntInPage);printf(%s %d %s %d, studi.gender,studi.age,studi.phone,studi.stature); cntInPage+;i+;GotoXY(10, 24);printf(=);GotoXY(10, 25);if(i count)printf(按任意键继续显示下一页.);elseprintf(查询结束,按任意键退出);getch(); void sort_stature() int pagelen = 20;/一页显示的记录数int cntInPage; int count;int i = 0; FILE *fp; if(fp=fopen(stuType, r)=NULL) printf(can not open filen); return;for(int k=0; k100& !feof(fp); k+) fread(&studk, sizeof(struct stuType), 1, fp); count=k-1; fclose(fp); while(i count)system(cls);GotoXY(10, 1);printf(共有 %d 位同学,每页显示 %d 个记录, count, pagelen);GotoXY(10, 2);printf(=);GotoXY(10, 3);printf( 姓名 性别 年龄 手机 身高);cntInPage = 1;while(icount & cntInP
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 高一物理电磁感应现象中的能量转换原理教学教案
- 科学实验室:科学实验活动教学计划
- 写人作文蜡烛老师750字(10篇)
- 时尚猫咪课件
- 时尚分销专业知识培训课件
- 读后感读闪着泪光的决定有感500字8篇
- 数据保护工具的合规性与隐私保障方案
- 我爱我温馨和谐的家550字13篇范文
- 纪检委员工作职责
- 文化娱乐行业市场趋势报告表
- 《肝硬化腹水中西医结合诊疗专家共识(2025年)》解读课件
- 旭化成分离膜装置(杭州)有限公司建设项目报告表
- 湖北摊贩备案管理办法
- (2025年)江西省九江市辅警协警笔试笔试预测试题含答案
- 员额法官考试试题及答案
- 2025年深圳市中考历史试卷真题(含答案详解)
- 注浆工安全知识题库
- GB/T 45359.5-2025海工平台定位系泊纤维绳索第5部分:芳纶
- 2025年全国新高考II卷真题2卷语文+数学+英语试卷(含答案)
- 2025至2030中国水飞蓟提取物行业项目调研及市场前景预测评估报告
- 2025年贵州毕节市金沙县国有资本投资运营集团有限公司招聘笔试参考题库含答案解析
评论
0/150
提交评论