c语言课设之学生证管理系统.doc

上传人:椰子壳 文档编号:5175483 上传时间:2020-02-15 格式:DOC 页数:31 大小:296.50KB
返回 下载 相关 举报
c语言课设之学生证管理系统.doc_第1页
第1页 / 共31页
c语言课设之学生证管理系统.doc_第2页
第2页 / 共31页
c语言课设之学生证管理系统.doc_第3页
第3页 / 共31页
c语言课设之学生证管理系统.doc_第4页
第4页 / 共31页
c语言课设之学生证管理系统.doc_第5页
第5页 / 共31页
亲,该文档总共31页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

《c语言课设之学生证管理系统.doc》由会员分享,可在线阅读,更多相关《c语言课设之学生证管理系统.doc(31页珍藏版)》请在三一文库上搜索。

1、学生证的管理程序 C语言课程设计报告一、 题目要求该程序应该具有下列功能:1、录入某位学生的学生证信息。学生证应该包照自含的信息请参己的学生证;2、给定学号,显示某位学生的学生信息;3、给定某个班级的班号,显示该班所有学生的学生证信息4、给定某位学生的学号,修改该学生的学生信息;5、给定某位学生的学号,删除该学生的学生信息;6、提供一些统计各类信息的功能。输入要求应用程序后,在屏幕上显示一个菜单。用户可以根据要求选定相应的操作项目。进入每个操作后,根据应用程序的提示信息,从键盘输入相应的信息。输出要求1、 应用程序运行后,要在屏幕上显示一个菜单;2、 要求用户输入数据时,要给出清晰、明确的提示

2、信息,包括输入的数据内容、格式及结束方式等。提示设计一个结构体类型和一维数组类型,用来保存学生证内容;二、 需求分析 根据题目要求,由于学生信息是一个有不同类型的变量组成,因此,应提供结构体操作,在程序中需要浏览学生信息,应提供显示、查找、修改、删除、统计等操作。另外还应该提供键盘式的选择菜单实现功能选择。三、 总体设计学生证的管理程序主要包含学生信息的录入、修改、删除、查询、统计等模块。为了各模块的独立性,将显示模块分别镶嵌在录入、修改、删除、查询、统计等模块中。学生证管理程序录 入模 块查 询模 块修 改模 块删 除模 块统 计模 块四、 详细分析1、 主函数分析主函数的设计简洁,只提供加

3、录入、修改、删除、查询、统计和显示等函数的调用和加载功能。其中各功能模块用菜单方式选择。并将main()函数体内的界面选择部分部分语句单独抽出来做一个独立的函数,目的在于系统执行完每部分功能模块后能更方便返回到系统界面。menu()函数从主函数中独立出来后,表面的主函数只是起一个程序开始的作用,其主要功能被独立出来的被调用的menu()函数所取代。menu()函数主要完成菜单的输出和被选择的项目的输入和相应执行函数的调用。并将已经拥有的信息从指定文件中读取到结构体st中,以便执行其他的功能性函数。成功后需要关闭文件。流程图显示一系列功能选项加载已有信息输入n,判断n是否是1-6根据的值调用各功

4、能模块函数NY程序/*menu*/menu() int n,w,i,j; STU *st; FILE *fp; fp=fopen(student1.txt,wb+); if(!fp) printf(Document error! ); exit(0); else fread(&i,2,1,fp); fclose(fp); j=i+1; st=(STU*)malloc(j*sizeof(STU); do printf(ntt*MENU*nn); printf(ttt1.Input information of studentn);/输入学生信息 printf(ttt2.Inquiries inf

5、ormation of studentn)/显示学生信息; printf(ttt3.Changes information of studentn);/修改学生信息 printf(ttt4.Delete information of studentn);/删除学生信息 printf(ttt5.Statistic information of studentn);/统计学生信息 printf(ttt6.Exit);/结束 printf(nn2tt*n); printf(Choice your number(1-6) bbbbbbb); scanf(%d,&n); if(n6) w=1;getch

6、ar(); else w=0;free(st); while(w=1); switch(n) case 1:input(i,st);break; case 2:inquiries(i,st);break; case 3:change(i,st);break; case 4:delete(i,st);break; case 5:statistic(i,st);break; case 6:exit(0);break; 2、各功能模块设计(1) 输入模块设计 分析在向指定文件输出学生信息及录入信息前需要将输入的学生证号进行检测,该检测是在结构体中st元素的学号项值比较而得出。如果已经存在的序号拒绝录

7、入,如果还没有输入的学生证号就按提示继续输入学生信息信息。输入成功后显示刚输入的信息并将信息输出到指定文件的末尾。成功后将释放机构体指针;关闭文件并返回到menu()函数继续选择并执行其他操作。流程图输入新加学号b,判断是否重复按提示输入姓名等其他信息将信息存储在STU型结构体中将信息存储到指定文件末尾NY关闭文件、释放结构体指针返回到menu()函数输出刚输入的信息程序/*input*/void input(int k,STU *st) int n,i; FILE *fp; long b; STU student_1; printf(Please input your number bbbb

8、bbb);/输入学号 scanf(%ld,&b); printf(nPlease input your name bbbbbbbbb);/输入名字 scanf(%s,student_1.name); printf(nPlease input you sex male(1) or female(2) bbbbbbb);/输入性别 scanf(%d,&student_1.sex); printf(nPlease input you Class bbbbbbb);输入班号 scanf(%ld,&student_1.classes); printf(nPlease input you date of

9、birth bbbbbbb);输入出生日期 scanf(%ld,&student_1.birth); fp=fopen(student1.txt,ab); if(!fp) printf(Document error! ); exit(0); elsefprintf(fp,%ld%s%d%ld%ld,b,student_1.name,student_1.sex,student_1.classes,student_1.birth);printf(%ld%s%d%ld%ld,b,student_1.name,student_1.sex,student_1.classes,student_1.birt

10、h); n=k+1; rewind(fp); fprintf(fp,%d,n); fclose(fp); free(st); menu();2、查询模块分析查询的主要方式就是通过学号查询,查询时需要通过输入学号并按学生信息储存逐个核对,如果出现发现相同信息则输出该同学的其他信息,没有发现相同的信息则提示未找到并返回到menu()函数继续选择并执行其他操作。该查询也是通过机构体st的元素项的比较得出。运行结束后需要关闭文件并释放机构体指针的空间。一系列功能选项流程图“NO”输入n,判断n的值是否是14,查找出生日期查找班级查找学号返回到menu返回到menu返回到menu程序/*inquirie

11、s*/ void inquiries(int k,STU *st) int i,j=0,n,p,w; long a; do printf(ntt*INQUIRIE MENU*nn); printf(ttt1.Inquiries school numbern); printf(ttt2.Inquiries classesn); printf(ttt3.Inquiries date of birthn); printf(ttt4.Back to menun); printf(nntt*n); printf(Choice your number(1-4) bbbbbbb); scanf(%d,&n)

12、; if(n4) w=1;getchar(); else w=0; while(w=1); switch(n) case 1:j=0;printf(Please input your inquiries school number bbbbbbb); scanf(%ld,&a); for(i=0;ik;i+)if(sti.num=a) j=1;p+; printf(%ld%s%d%ld%ld,sti.num,sti.name,sti.sex,sti.classes,sti.birth);if(!j) printf(There is no this school number!);else pr

13、intf(Success.There are %d student.,p);inquiries(k,st);break; case 2:j=0;printf(Please input you class number bbbbbbb); scanf(%ld,&a);for(i=0;ik;i+)if(sti.classes=a) i=1;p+; printf(%d%s%d%d%ld,sti.num,sti.name,sti.sex,sti.classes,sti.birth); if(!j) printf(There is no this Class!);else printf(Success.

14、There are %d student.,p);inquiries(k,st);break; case 3:j=0; printf(Please input you date of birth bbbbbbb);scanf(%ld,&a);for(i=0;ik;i+)if(sti.birth=a) i=1;p+; printf(%d%s%d%d%ld,sti.num,sti.name,sti.sex,sti.classes,sti.birth); if(!j) printf(There is no this date of birth!);else printf(Success.There

15、are %d student.,p);inquiries(k,st);break; case 4:free(st);menu();break; 3、修改模块分析修改一个学生的信息首先要利用学生证号在已经存储的信息中找到该学生的信息并输出该学生的具体信息,再在阅读完信息之后选择所需要修改的信息。修改成功之后需要将已经更改的信息输出到屏幕和指定文件保存。成功之后返回到menu()函数继续选择并执行其他操作。其中的信息比较也是通过输入学号和机构体中的学号项逐个比较。流程图显示一系列功能选项输入n,判断n是否是0-6返回menu()函数n=1n=4n=3n=2Nn=5n=6改学号改姓名改性别改班级改出

16、生重输入程序/*change*/ void change(int k,STU *st) int a,i,n,w,j=0,p,q=0; FILE *fp; fp=fopen(student1,wb); if(!fp) printf(Document error! ); exit(0); printf(Plese input you change number bbbbbbb); scanf(%ld,&a); for(i=0;ik;i+) if(sti.num=a) j=1;p=i; do printf(ntt*CHANGES MENU*); printf(nttt1.Change Number)

17、;/修改学号 printf(nttt2.Change Name);/修改名字 printf(nttt3.Change Sex);/修改性别 printf(nttt4.Change classes);修改班号 printf(nttt5.Change Date of birth);修改出生日期 printf(nttt6.Back); printf(ntt*n); printf(nChoice your number(1-6) bbbbbbb); scanf(%d,&n); if(n6) w=1;getchar(); else w=0; while(w=1); switch(n) case 1:pr

18、intf(nPlease input your new number bbbbbbb); scanf(%ld,&sti.num);q=1;change(k,st);break; case 2:printf(nPlease input your new name bbbbbbbbb); scanf(%s,sti.name);q=1;change(k,st);break; case 3:printf(nPlease input your right sexmale(M) or female(f) bbbbbbb); scanf(%d,&sti.sex);q=1;change(k,st);break

19、; case 4:printf(nPlease input your new classes bbbbbbb); scanf(%ld,&sti.classes);q=1;change(k,st);break; case 5:printf(nPlease input your right date of birth bbbbbbb); scanf(%ld,sti.birth);q=1;change(k,st);break; case 6:rewind(fp); fprintf(fp,%d,k); for(i=0;ik;i+) fprintf(fp,%ld%s%d%ld%ld,sti.num,st

20、i.name,sti.sex,sti.classes,sti.birth); if(p) printf(The changed information are:%ld%s%d%ld%ld,stq.num,stq.name,stq.sex,stq.classes,stq.birth); free(st);fclose(fp);menu(); if(!j) printf(There is no this student);free(st);menu(); 4、删除模块分析删除一个给定学号的学生的信息时需要在学号输入后在已经有的学生信息中逐个查找,发现该信息后直接将后一个结构体元素复制个被删除的元素

21、,依次类推,直到倒数第二个元素被复制,这时将结构体的有效元素个数减1便完成该学生信息的删除。在删除成功后需要将被改变的学生信息输出到指定文件。成功之后释放结构体空间,关闭文件并返回到menu()函数继续选择并执行其他操作。流程图输入要删除的学生信息的学号查询是否存在输入学号的信息在结构体数组中逐个代替法删除删除的学号并将更改后的信息写入指定文件输出被删除学生的其他信息返回到menu()函数YYN程序/*delete*/ delete(int k,STU *st) int i,j,b; long a; FILE *fp; printf(Please input your delete schoo

22、l number bbbbbbb); scanf(%ld,&a); for(i=0;ik;i+) if(sti.num=a) printf(The deleted information are:%ld%s%d%ld%ld,sti.num,sti.name,sti.sex,sti.classes,sti.birth);for(;ik-1;i+) sti.num=sti+1.num; strcpy(sti.name,sti+1.name); sti.sex=sti+1.sex; sti.classes=sti+1.classes; sti.birth=sti+1.birth; j=k-1;fp=

23、fopen(student1,wb); if(!fp) printf(Document error! ); exit(0); rewind(fp); fprintf(fp,%d,j); for(i=0;ij;i+) fprintf(fp,%ld%s%d%ld%ld,sti.num,sti.name,sti.sex,sti.classes,sti.birth); free(st);fclose(fp);menu(); break; else printf(There is no this schol number!); free(st);fclose(fp);menu(); 5、统计模块分析统计

24、的主要项目有姓名、班级、性别和出生日期,并通过可输入菜单完成统计项目的选择和相应功能的执行。在统计时是将输入的信息和结构体中的已有信息进行比较,如果出现同样的信息便输出该同学的信息并进行记数统计。完成后释放结构体指针空间,返回到menu()函数继续选择并执行其他操作。流程图显示一系列功能选项输入n,判断n是否是1-5输出统计姓 名输出统计班 级输出统计性 别输出统计生 日关闭文件释放指针返回统计函数继续统计n=1n=2n=3n=4n=5N返回主函数程序/*statistic*/ void statistic(int k,STU *st) int n,w,i,b,p=0; long a; int

25、 name10; do printf(ntt*STATISTIC MENU*nn); printf(ttt1.Name statisticn); printf(ttt2.classes statisticn); printf(ttt3.Sex statisticn); printf(ttt4.Date of birth statisticn); printf(ttt5.Back); printf(nntt*n); printf(Choice your number(1-5) bbbbbbb); scanf(%d,&n); if(n5) w=1;getchar(); else w=0; whil

26、e(w=1); switch(n) case 1:printf(nPlease input you statistic name bbbbbbbbb); scanf(%s,name); for(i=0;ik;i+)if(!strcmp(sti.name,name) p+; printf(%ld%s%d%ld%ld,sti.num,sti.name,sti.sex,sti.classes,sti.birth); if(p) printf(There are %d students.,p); statistic(k,st); case 2:printf(nPlease input you clas

27、ses bbbbbbb); scanf(%ld,&a); for(i=0;ik;i+)if(sti.classes=a) p+; printf(%ld%s%d%ld%ld,sti.num,sti.name,sti.sex,sti.classes,sti.birth); if(p) printf(There are %d students.,p); statistic(k,st); case 3:printf(nPlease input you statistic sex M or F bbbbbbb); scanf(%d,&b); for(i=0;ik;i+)if(sti.sex=b) p+;

28、 printf(%ld%s%d%ld%ld,sti.num,sti.name,sti.sex,sti.classes,sti.birth); if(p)printf(There are %d students.,p); statistic(k,st); case 4:printf(nPlease input you date of birth bbbbbbb); scanf(%ld,&a); for(i=0;ik;i+) if(sti.classes=a) p+; printf(%ld%s%d%ld%ld,sti.num,sti.name,sti.sex,sti.classes,sti.bir

29、th); if(p)printf(There are %d students.,p); statistic(k,st); case 5:free(st);menu(); 五、 上机操作六、 源程序#include#include#include#include#define STU struct student STU long num; char name20; int sex; long classes; long birth; ;/*input*/void input(int k,STU *st) int n,i; FILE *fp; long b; STU student_1; pri

30、ntf(Please input your number bbbbbbb); scanf(%ld,&b); for(i=0;ik;i+) if(sti.num=b) printf(nThe school number is repeat!n); free(st);menu(); else printf(nPlease input your name bbbbbbbbb); scanf(%s,student_1.name); printf(nPlease input you sex male(1) or female(2) bbbbbbb); scanf(%d,&student_1.sex);

31、printf(nPlease input you Class bbbbbbb); scanf(%ld,&student_1.classes); printf(nPlease input you date of birth bbbbbbb); scanf(%ld,&student_1.birth); fp=fopen(student1.txt,ab); if(!fp) printf(Document error! ); exit(0); elsefprintf(fp,%ld%s%d%ld%ld,b,student_1.name,student_1.sex,student_1.classes,st

32、udent_1.birth);printf(%ld%s%d%ld%ld,b,student_1.name,student_1.sex,student_1.classes,student_1.birth); n=k+1; rewind(fp); fprintf(fp,%d,n); fclose(fp); free(st); menu();/*inquiries*/ void inquiries(int k,STU *st) int i,j=0,n,p,w; long a; do printf(ntt*INQUIRIE MENU*nn); printf(ttt1.Inquiries school

33、numbern); printf(ttt2.Inquiries classesn); printf(ttt3.Inquiries date of birthn); printf(ttt4.Back to menun); printf(nntt*n); printf(Choice your number(1-4) bbbbbbb); scanf(%d,&n); if(n4) w=1;getchar(); else w=0; while(w=1); switch(n) case 1:j=0;printf(Please input your inquiries school number bbbbb

34、bb); scanf(%ld,&a); for(i=0;ik;i+)if(sti.num=a) j=1;p+; printf(%ld%s%d%ld%ld,sti.num,sti.name,sti.sex,sti.classes,sti.birth);if(!j) printf(There is no this school number!);else printf(Success.There are %d student.,p);inquiries(k,st);break; case 2:j=0;printf(Please input you class number bbbbbbb); scanf(%ld,&a);for(i=0;ik;i+)if(sti.classes=a) i=1;p+; printf(%d%s%d%d%ld,sti.num,sti.name,sti.sex,sti.classes,sti.birth); if(!j) printf(There is no this Class!);

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 项目管理


经营许可证编号:宁ICP备18001539号-1