c语言学生信息管理系统_第1页
c语言学生信息管理系统_第2页
c语言学生信息管理系统_第3页
c语言学生信息管理系统_第4页
c语言学生信息管理系统_第5页
已阅读5页,还剩19页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、#include#include#include#define MAX_S_NUM 100;struct stuTypechar name9;char gender3;char phone12;int age;float hight; struct stuType stuAry100;struct stuType Ary100;int n;FILE *fp;char ch;bool test=true;void GotoXY(int x,int y); void mainColumName();void DispColumName();void QueryColumName();void Qu

2、eryDispColumName();void QueryDispColumName1();void QueryName();void QueryName1();void QueryList();void DispErrorInfo();void ClDispInfo();void ClearInfo();void QuClearInfo();void ScanfInfo(stuType stu);void Input();void Query();void SortAry();void Modification();void statitics();/*主函数*/void main() wh

3、ile (test)/*ystem(cls); GotoXY(30,10); printf(同学通讯录管理系统(顺序结构查询)n); GotoXY(29,11); printf(=n); GotoXY(29,13); printf(1. 输入 2. 查询 3. 修改n); GotoXY(29,15); printf(4. 排序 5. 统计 6. 退出n); GotoXY(29,17); printf(=n); GotoXY(29,19); printf(请选择:); /getch();scanf(%d,&n); */mainColumName();if(n6)GotoXY(40,19);pri

4、ntf(输入无此选项); test=!test; switch(n)case 1 :/system(cls);DispColumName(); Input();test=!test; break;case 2 : /system(cls);QueryColumName(); Query();test=!test; break;case 3 : /system(cls);Modification(); test=!test; break;case 4 :SortAry();test=!test; break;case 5 :statitics();test=!test; break;case 6

5、 : system(cls); test=false; break;/*坐标定位*/void GotoXY(int x,int y)COORD c;c.X = x - 1;c.Y = y - 1;SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), c);/*输入显示模块*/void DispColumName()system(cls);GotoXY(30,10);printf(请输入各项信息n);GotoXY(25,11);printf(=n); GotoXY(2,13);printf(姓名:);GotoXY(20,13);pri

6、ntf(性别:);GotoXY(33,13);printf(手机号:);GotoXY(55,13);printf(年龄:);GotoXY(65,13);printf(身高(m):);GotoXY(15,15);printf(是否继续输入(Y/*):);/*输入显示*/void Input()int i=0;bool a=true;/int num;fp = fopen (stu.dat, a);if (fp=NULL)printf(The file stu.datis opened filed);exit(1);int count=0;while(a)ScanfInfo(stuAry);Got

7、oXY(35,15);/scanf(%s,&ch);fflush(stdin);Arycount=stuAryi;fwrite(&stuAryi,sizeof(struct stuType), 1, fp); count+;ch = getchar();if(ch=Y|ch=y) / fwrite(&stuAryi,sizeof(struct stuType), 1, fp); / Arycount=stuAryi; / count+; / fclose(fp); ClearInfo(); DispColumName();else a=false; test=!test;/mainColumN

8、ame();count=count-1; fclose(fp);/*查询模块方式*/void Query()int m;GotoXY(11,9);scanf(%d,&m);fflush(stdin);switch (m)case 1 : QueryDispColumName(); QueryDispColumName1(); break; case 2 :QueryName();QueryName1(); break;case 3 :QueryList(); break;case 0 : /system(cls);test=!test; break;/*修改模块方式*/void Modific

9、ation()int m = 0;int i = 0;int count = 0;int b = 0;char ch ,search9;bool a=true;system(cls);GotoXY(30,6);printf(修改信息);GotoXY(10,7);printf(=);GotoXY(10,9);printf(=);GotoXY(13,8);printf(请输入要修改人姓名:);while (a) GotoXY(33,8); scanf(%s,search); fflush(stdin); fp = fopen(stu.dat,r); if (fp=NULL) printf(The

10、file stu.dat is opened filed!); exit(1); while(!feof(fp)fread(&Arycount,sizeof(struct stuType),1,fp);count+; fclose(fp);/while (a)/rewind(fp);/ while (!feof(fp)char *ch1=A ,*ch2=search;for(i=0;icount;i+) /fread(&Arym,sizeof(struct stuType),1,fp); /char *ch1=A ,*ch2=search; if (strcmp

11、(A,search)=0) GotoXY(2,13); printf(姓名:); GotoXY(20,13); printf(性别:); GotoXY(33,13); printf(手机号:); GotoXY(55,13); printf(年龄:); GotoXY(65,13); printf(身高(m):); GotoXY(8,13); scanf(%s,stuA); fflush(stdin); GotoXY(26,13); scanf(%s,stuAryi.gender); fflush(stdin); GotoXY(42,13); scanf(%s,st

12、uAryi.phone); while(strlen(stuAryi.phone)!=11) DispErrorInfo(); GotoXY(25,19); printf(手机号码输入错误,应为11为数字!); GotoXY(42,13); printf( ); GotoXY(42,13); scanf(%s,&stuAryi.phone); fflush(stdin); ClDispInfo(); GotoXY(25,19); printf( ); GotoXY(61,13); scanf(%d,&stuAryi.age); while(stuAryi.age120) DispErrorIn

13、fo(); GotoXY(25,19); printf(年龄输入应在0-120之内); GotoXY(61,13); printf( ); GotoXY(61,13); scanf(%d,&stuAryi.age); fflush(stdin); ClDispInfo(); GotoXY(25,19); printf( ); GotoXY(75,13); scanf(%f,&stuAryi.hight); while (stuAryi.hight3) DispErrorInfo(); GotoXY(25,19); printf(身高应在0-3米之内); GotoXY(75,13); print

14、f( ); GotoXY(75,13); scanf(%f,&stuAryi.hight); fflush(stdin); Aryi=stuAryi;b+;/fwrite(&Aryi,sizeof(struct stuType), 1, fp); / fclose(fp); /count+;/fclose(fp); count=count-1;fp = fopen(stu.dat,w); for(i=0;icount;i+) fwrite(&Aryi,sizeof(struct stuType),1,fp); fclose(fp); if(b=0)GotoXY(37,8);printf(没有此

15、项); GotoXY(15,20); printf(是否继续修改(Y/*):); GotoXY(35,20); ch=getch(); fflush(stdin); if(ch=y|ch=Y) GotoXY(8,13); printf( );GotoXY(33,8);printf( ); GotoXY(26,13); printf( ); GotoXY(42,13); printf( ); GotoXY(61,13); printf( ); GotoXY(75,13); printf( ); else a=!a; test=!test;/*排序*/void SortAry()int i = 0

16、;int a,b,c;system(cls); GotoXY(25,3);printf(数据年龄升序显示);GotoXY(5,4); printf(=); GotoXY(6,5); printf(姓名 性别 手机号 年龄 身高(m); GotoXY(5,20); printf(=);fp = fopen(stu.dat,r);if (fp=NULL)printf(The file stu.dat is opened filed!);exit(1);while(!feof(fp)fread(&Aryi,sizeof(struct stuType),1,fp);i+;i=i-1;for(a=0;a

17、i-1;a+)for(b=a+1;b=Aryb.age) c=Arya.age;Arya.age=Aryb.age;Aryb.age=c;for(a=0;ai;a+)GotoXY(5,7+a); printf(%s,A);fflush(stdin); GotoXY(18,7+a); printf(%s,Arya.gender);fflush(stdin); GotoXY(29,7+a); printf(%s,Arya.phone);fflush(stdin); GotoXY(47,7+a); printf(%d,Arya.age);fflush(stdin); GotoXY(5

18、5,7+a); printf(%1.2f,Arya.hight);fflush(stdin);GotoXY(10,21);printf(信息显示完毕,按Esc键返回上一层.);if(getche()=27)test=!test;/*统计模块*/void statitics()int i=0;int count=0;int a;float age , hight ,sum2=0 ,sum1=0; system(cls);GotoXY(15,5);printf(信息统计);GotoXY(5,6);printf(=); fp = fopen (stu.dat,r); if(fp=NULL)print

19、f(The file stu.dat is opened filed!);exit(1);while(!feof(fp)fread(&Aryi,sizeof(struct stuType),1,fp);i+;count+;fclose(fp);count=count-1;GotoXY(5,7);printf(班级总人数:%d,count);for(a=0;acount;a+)sum1+=Arya.age;sum2+=Arya.hight;age = float ( sum1 )/ count;hight = sum2/ count;GotoXY(5,8);printf(班级平均年龄是:%1.2

20、f,age);GotoXY(5,9);printf(班级平均身高(m):%1.2f ,hight);GotoXY(5,11);printf(信息显示完毕,按Esc键返回上一层.);if(getche()=27)test=!test;/*输入模块显示信息*/void ScanfInfo(stuType stu) int i=0;GotoXY(8,13); scanf(%s,); fflush(stdin); GotoXY(26,13); scanf(%s,stui.gender);fflush(stdin); GotoXY(42,13); scanf(%s,stui.phone

21、);while(strlen(stui.phone)!=11)DispErrorInfo(); GotoXY(25,19);printf(手机号码输入错误,应为11为数字!);GotoXY(42,13);printf( );GotoXY(42,13); scanf(%s,&stui.phone);fflush(stdin);ClDispInfo(); GotoXY(25,19);printf( ); GotoXY(61,13); scanf(%d,&stui.age);while(stui.age120)DispErrorInfo();GotoXY(25,19);printf(年龄输入应在0-

22、120之内);GotoXY(61,13);printf( );GotoXY(61,13);scanf(%d,&stui.age);fflush(stdin);ClDispInfo(); GotoXY(25,19);printf( ); GotoXY(75,13); scanf(%f,&stui.hight);while (stui.hight3)DispErrorInfo();GotoXY(25,19);printf(身高应在0-3米之内);GotoXY(75,13);printf( );GotoXY(75,13);scanf(%f,&stui.hight);fflush(stdin);ClD

23、ispInfo(); GotoXY(25,19);printf( );/GotoXY(35,15);/scanf(%s,&ch);/*清除显示信息*/void ClearInfo()GotoXY(8,13);printf( );GotoXY(26,13);printf( );GotoXY(42,13);printf( );GotoXY(61,13);printf( );GotoXY(75,13);printf( );GotoXY(35,15);printf( );/*/ /*void ClearInfo1()GotoXY(40,13);printf( );GotoXY(8,15+b);prin

24、tf( );GotoXY(26,15+b);printf( );GotoXY(42,15+b);printf( );GotoXY(61,15+b);printf( );GotoXY(75,15+b);printf( );GotoXY(15,25);printf( ); */ /*主体框架模块*/ void mainColumName()system(cls); GotoXY(30,10); printf(同学通讯录管理系统(顺序结构查询)n); GotoXY(29,11); printf(=n); GotoXY(29,13); printf(1. 输入 2. 查询 3. 修改n); GotoX

25、Y(29,15); printf(4. 排序 5. 统计 6. 退出n); GotoXY(29,17); printf(=n); GotoXY(29,19); printf(请选择:); /getch();scanf(%d,&n);/*提示错误信息*/void DispErrorInfo()GotoXY(33,17);printf(错误信息提示);GotoXY(25,18);printf(=n);test=!test;/*清除提示错误信息*/void ClDispInfo()GotoXY(33,17);printf( );GotoXY(25,18);printf( );/*查询模块框架*/vo

26、id QueryColumName()system(cls);GotoXY(3,1);printf(1.顺序查询:);GotoXY(3,3);printf(2.按姓名查询:);GotoXY(3,5);printf(3.列表查询:);GotoXY(3,7);printf(0.结束查询);GotoXY(3,9);printf(请选择:); /*顺序查询模块框架*/ void QueryDispColumName()system(cls);GotoXY(30,10);printf(顺序显示通讯录中各该同学的信息n);GotoXY(25,11);printf(=n); GotoXY(2,13);pri

27、ntf(姓名:);GotoXY(20,13);printf(性别:);GotoXY(33,13);printf(手机号:);GotoXY(55,13);printf(年龄:);GotoXY(65,13);printf(身高(m):);GotoXY(15,15);printf(是否继续查询(Y/*):);/*顺序查询模块显示信息*/void QueryDispColumName1() int i=0;int m=0; bool a=true;char ch2;fp = fopen (stu.dat, r);if (fp=NULL)printf(The file stu.datis opened

28、filed);exit(1);while(!feof(fp)fread(&Arym,sizeof(struct stuType),1,fp); m+;m=m-1;while(im&a)GotoXY(8,13);printf(%s,A); fflush(stdin); GotoXY(26,13); printf(%s,Aryi.gender); fflush(stdin); GotoXY(42,13); printf(%s,Aryi.phone); fflush(stdin); GotoXY(61,13);printf(%d,Aryi.age); fflush(stdin); G

29、otoXY(75,13); printf(%1.2f,Aryi.hight);fflush(stdin); GotoXY(35,15);ch2=getchar(); if(ch2=Y|ch2=y) ClearInfo(); i+; else system(cls); a=!a; QueryColumName(); Query(); if(i=m) GotoXY(8,13); printf(%s,A); GotoXY(26,13); printf(%s,Aryi-1.gender); GotoXY(42,13); printf(%s,Aryi-1.phone); GotoXY

30、(61,13); printf(%d,Aryi-1.age); GotoXY(75,13); printf(%1.2f,Aryi-1.hight); GotoXY(8,15); printf( ); printf(已经查询到最后一条记录,按Esc返回上一层.); if(getche()=27) QueryColumName(); Query();ClearInfo();/*按姓名查询模块框架*/void QueryName()system(cls);GotoXY(15,10);printf(按输入的姓名查询显示该同学的信息n);GotoXY(10,11);printf(=n); GotoXY(

31、2,15);printf(姓名:);GotoXY(20,15);printf(性别:);GotoXY(33,15);printf(手机号:);GotoXY(55,15);printf(年龄:);GotoXY(65,15);printf(身高(m):);GotoXY(20,13);printf(请输入要查询的姓名:); /*按姓名查询模块框架显示信息*/void QueryName1()int m=0;int i=0;int b=0;bool a=true ;char ch , search9;fp = fopen (stu.dat, r);if (fp=NULL)printf(The file

32、 stu.datis opened filed);exit(1);/*while(!feof(fp)fread(&Arym,sizeof(struct stuType),1,fp); / m+;/fclose(fp);char *str1 = A, *str2 = search, *ptr; */ GotoXY(40,13);scanf(%s,&search);ch=getchar();fflush(stdin); while(a) rewind(fp);while(!feof(fp) fread(&Arym,sizeof(struct stuType),1,fp); char

33、 *str1 = A, *str2 = search; /if(ptr=strstr(str1,str2) if(strcmp(A,search)=0) GotoXY(8,15+b); printf(%s,A); fflush(stdin); GotoXY(26,15+b); printf(%s,Aryi.gender); fflush(stdin); GotoXY(42,15+b); printf(%s,Aryi.phone); fflush(stdin); GotoXY(61,15+b); printf(%d,Aryi.age); fflus

34、h(stdin); GotoXY(75,15+b); printf(%1.2f,Aryi.hight); fflush(stdin); b+; if(b=0)GotoXY(8,15+b); printf( ); GotoXY(26,15+b); printf( ); GotoXY(42,15+b); printf( ); GotoXY(61,15+b); printf( ); GotoXY(75,15+b); printf( );b-; GotoXY(15,25); printf( ); GotoXY(40,13); scanf(%s,&search);b=0; else system(cls); QueryColumName(); a=!a;Query(); /*GotoXY(45,13);printf(没有此选项);GotoXY(15,25); printf(是否继续查询(Y/*):);GotoXY(35,25); ch=getchar(); */ fclose(fp);/*GotoXY(45,13);printf(没有此选项);GotoXY(15,25); printf(是否继续查询(Y/*):);GotoXY(35,25); ch=getc

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论