C语言课程设计报告学生成绩管理系统.doc

上传人:rrsccc 文档编号:9924591 上传时间:2021-04-04 格式:DOC 页数:18 大小:170KB
返回 下载 相关 举报
C语言课程设计报告学生成绩管理系统.doc_第1页
第1页 / 共18页
C语言课程设计报告学生成绩管理系统.doc_第2页
第2页 / 共18页
C语言课程设计报告学生成绩管理系统.doc_第3页
第3页 / 共18页
C语言课程设计报告学生成绩管理系统.doc_第4页
第4页 / 共18页
C语言课程设计报告学生成绩管理系统.doc_第5页
第5页 / 共18页
点击查看更多>>
资源描述

《C语言课程设计报告学生成绩管理系统.doc》由会员分享,可在线阅读,更多相关《C语言课程设计报告学生成绩管理系统.doc(18页珍藏版)》请在三一文库上搜索。

1、目录一、 需求分析 1二、 概要设计 11、 系统功能组成框图12、 数据结构设计23、 模块说明2三、 详细设计21、 模块设计代码22、 程序详细代码33、 函数的调用11四、 调试分析11五、 用户手册11六、 测试数据15七、 附件16八、 心得体会16学生成绩管理系统一、需求分析1、此程序里包含着多个属性,所以类型为结构体类型2、程序内的对象调入和调出都需循环体类型的文件操作实现3、学生成绩的信息修改、插入、删除都需保存,而保存需进行文件的读写操作4、排序操作可采用冒泡排序和选择法排序5、主函数中根据不同选择执行不同操作可通过“多分支选择语句switch”实现二、概要设计学生成绩管理

2、系统1系统功能组成框图输入系统修改系统输出系统删除系统插入系统按学号查询系统升序按姓名降序按学号排序系统升序按总分降序2数据结构设计成绩管理系统为结构体struct 结构体名定义名字的长度,学号的长度定义性别三门课程的成绩总分平均分3模块说明1、每一条记录包括一个学生的学号、姓名、性别、3门成绩、总分、平均成绩。2、输入功能:可以一次完成规定数字记录的输入。3、输出功能:完成全部学生记录的显示。4、插入功能:按学生的学号、姓名、性别、三门课程成绩、总分、平均分插入学生信息。5、修改功能:选择学生进行修改6、排序功能:按学生总分进行升降排序。7、查找功能:完成按姓名或者学号查找学生记录,并显示。

3、8、删除功能:选择学生的学号或者名字进行核对,确定之后删除三、 详细设计1、模块设计代码 input( )/*输入模块*/ output( )/*输出模块*/ search( )/*查询模块*/ modify( )/*修改模块*/ delete( )/*删除模块*/ insert( )/*插入模块*/ sort()/*排序模块*/2、程序详细代码#include /*头文件(源文件)*/struct stu /*定义一个结构体用来存放学生学号、三门课成绩、总分及平均成绩*/char num10; /*学号长度*/ char name10; /*姓名长度*/char sex; /*性别类型*/

4、int score3; /*三门课程类型*/* float sum; /*总分类型*/ float ave; /*平均分类型*/student55; int n=3; /*定义n=3*/main() /*主函数*/char ch; /*定义类型*/while(1) /*循环(死循环)主界面*/system(cls);printf(nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn);clrscr(); printf(*n);printf( welcome to the students management system n ); printf(*n);printf( * * n)

5、; printf( * * n); printf( * * n); printf( *1:input*n); printf( *2:output*n); printf( *3:search*n); printf( *4:delete*n); printf( *5:insert*n); printf( *6:modify* n ); printf( *7:sort* n); printf( *8:exit* n); printf( * n); printf( * n); printf( * n); printf( * n); printf( *n); printf(nntt please inp

6、ut the option:n); ch=getchar(); switch(ch) case1: input();break; case2: output();break; case3: search();break; case4: delete();break; case5: insert();break; case6: modify();break; case7: sort();break; case8: exit(0);input() /*输入*/FILE *fp; /*定义指针 文件*/int i,j; /*定义i j*/if(fp=fopen(stu.dat,w+)=NULL) /

7、*若文件打不开*/printf(cannot open the file); /*显示cannot open the file */exit(0); /*退出*/printf(please input the students imformation:n); /*显示“请输入学生信息”*/for(i=0;in;i+) /*从0开始,i3 一次次叠加*/printf(The %d,i+1); /*输出第几个学生*/ printf(the number:); /*输出学号*/ scanf(%s,studenti.num); /*输入这个学生的学号*/ printf(n the name:); /*

8、输出学生姓名*/ scanf(%s,studenti.name); /*输入这个学生的姓名*/ printf(n the sex: ); /*输出性别*/ scanf( %c,&studenti.sex); /*输入这个学生的性别*/ printf(n the 3 score:); /*输出3门科目的分数*/ studenti.sum=0; /*定义这个学生刚开始的总分为0*/ for(j=0;j3;j+) /*j从0开始,j3,一次次叠加*/ printf(the score %d :,j+1); /*输出科目的分数*/ scanf(%d,&studenti.scorej); /*输入这个学

9、生的学号和科目*/ studenti.sum+=studenti.scorej; /*学生的总分,SUM+的意思为从0开始叠加*/ studenti.ave=studenti.sum/3.0; /*学生的平均分*/ fwrite(student,sizeof(struct stu),n,fp); /*将这个学生的信息写入指针文件中*/getch();fclose(fp); /*关闭文件*/output() /*输出文件*/FILE *fp; /*定义指针 文件*/ int i; /*定义i */ if(fp=fopen(stu.dat,r)=NULL) /*若文件打不开*/printf(can

10、not open the FILE); /*显示cannot open the file */ exit(0); /*退出*/ n=0; while(fread(&studentn,sizeof(struct stu),1,fp)=1) n+; /*循环,每读取时都为一次*/ printf(num name sex score1 score2 score3 sum ave n); /*若读取成功则输出学生的学号姓名性别 123科目成绩 总分平均分*/ for(i=0;in;i+) printf(%st%st%ct%dt%dt%dt%ft%fn,studenti.num,studenti.nam

11、e, studenti.sex,studenti.score0,studenti.score1,studenti.score2, studenti.sum,studenti.ave); /*输出学号,姓名,性别,成绩,成绩,成绩,总分,平均分*/ fclose(fp); /*关闭文件*/ getch(); insert() /*插入*/ FILE *fp; /*定义指针文件*/int i,j,m,x; /*定义i,j,m,x*/if(fp=fopen(stu.dat,ab+)=NULL) /*若文件打不开*/printf(cannot open the file); /*显示cannot op

12、en the file */ exit(0);/*退出*/n=0;while(fread(&studentn,sizeof(struct stu),1,fp)=1) n+; /*循环,每读取时都为一次*/printf(please input the the count:n); /*请输入数字*/scanf(%d,&m); /*输入增加的数目*/printf(please input the students information:n); /*请输入插入学生的信息*/for(i=n;in+m;i+) printf(The %d,i+1); /*输出一项*/ printf(the number

13、:); /*输出数字*/ scanf(%s,studenti.num); /*输入插入学生的学号*/ printf(nthe name:); /*学生姓名*/ scanf(%s,studenti.name); /*输入插入学生的姓名*/ printf(n the sex: ); /*学生性别*/ scanf( %c,&studenti.sex); /*输入插入学生的性别*/ printf(n the 3 score:); /*三门课程的成绩*/ studenti.sum=0;/*总分初始为0*/ for(j=0;j3;j+) printf(the score %d :,j+1);/*课程的成绩

14、累加*/ scanf(%d,&studenti.scorej); /*输入插入学生第几门成绩*/ studenti.sum+=studenti.scorej; /*学生总分=三门课程成绩的累加*/ studenti.ave=studenti.sum/3.0; /*学生平均分=学生的总分/3*/ for(i=n;in+m;i+) fwrite(&studenti,sizeof(struct stu),1,fp); /*保存输入学生信息的数据进文件*/fclose(fp); /*关闭文件*/modify() /*修改*/FILE *fp; /*定义指针文件*/int i,j;char name10

15、; /*定义name的长度*/ char ch; if(fp=fopen(stu.dat,rb+)=NULL) /*若文件打不开*/ printf(cannot open the FILE); /*显示cannot open the file */ exit(0); /*退出*/ n=0;while(fread(&studentn,sizeof(struct stu),1,fp)=1) n+;printf(please input the name of the student who should be modify!n); /*请输入要修改学生的姓名*/printf(ttt the nam

16、e:n); /*输出姓名*/scanf(%s,name); /*姓名*/for(i=0;in;i+)if(strcmp(name,studenti.name)=0) /*比较输入学生的姓名是否符合文件中学生的姓名*/printf(%st%st%ct%dt%dt%dt%ft%fn,studenti.num,studenti.name,studenti.sex,studenti.score0,studenti.score1,studenti.score2,studenti.sum,studenti.ave); /*输出学生的学号,姓名,性别,成绩,成绩,成绩,总分,平均分*/break;print

17、f(nttt Do you modify it, Y/N? ); /*你要修改吗?Y/N*/scanf( %c,&ch); if(ch=y|ch=Y) /*y=Y*/printf(The %d,i+1); /*第一项*/ printf(the number:); /*学号*/ canf(%s,studenti.num); /*输入学生的学号*/ rintf(nthe name:); /*姓名*/ canf(%s,studenti.name); /*输入学生的姓名*/ rintf(nthe sex: (MF) ); /*学生的性别(MF)*/ canf( %c,&studenti.sex); /

18、*输入学生的性别*/ printf(n the 3 score:); /*三门课程的成绩*/ tudenti.sum=0; /*初始总分为0*/ for(j=0;jnumn); /*输出“选择1为学号排序”*/printf(ntt 2-sumn); /*输出“选择2为总分排序”*/printf(please select:n); /*请选择*/scanf( %c,&ch1); /*输入1*/if(ch1=1) /*若选择1 */printf(nt u-up); /*输出u=up*/printf(nt d-down); /*输出d=down*/printf(please select:n); /

19、*输出“请选择”*/scanf( %c,&ch2); /*输入选择*/if(ch2=u|ch2=U) /*选择中的u=U*/for(i=0;in-1;i+) for(j=0;j0) /*比较studentj.num和studentj+1.num的长度0*/m=studentj;studentj=studentj+1;studentj+1=m; /*小点的数字覆盖前面大点的数字,大点的数字往后移*/ if(ch2=D|ch2=d) /*选择中的d=D*/for(i=0;in-1;i+) for(j=0;jn-i-1;j+) if(strcmp(studentj.num,studentj+1.nu

20、m)up); /*输出u=up*/ printf(nt d-down); /*输出d=down*/ printf(please select:n); /*输出“请选择”*/ scanf( %c,&ch2);/*输入选择*/ if(ch2=u|ch2=U)/*选择中的u=U*/for(i=0;in-1;i+) for(j=0;jstudentj+1.sum) /*比较studentj.sumstudentj+1.sum的长度*/m=studentj;studentj=studentj+1;studentj+1=m; /*小点的数字覆盖前面大点的数字,大点的数字往后移*/ if(ch2=d|ch2

21、=D) /*选择中的d=D*/for(i=0;in-1;i+) for(j=0;jn-i-1;j+) if(studentj.sumstudentj+1.sum) /*若studentj.sumnumn); /*选择1 为学号*/printf(ntt 2-namen); /*选择2为姓名*/printf(please select:n); /*请选择*/scanf( %c,&ch); /*输入选择*/if(ch=1) /*选择1*/printf(please input the num: n); /*显示请输入学号*/ scanf(%s,num); /*输入学号*/ for(i=0;in;i+

22、) if(strcmp(num,studenti.num)=0) /*比较num和studengti.num的长度*/ printf(%st%st%ct%dt%dt%dt%ft%fn,studenti.num,studenti.name,studenti.sex, studenti.score0,studenti.score1,studenti.score2,studenti.sum,studenti.ave); /*输入学生的学号,姓名,性别,成绩,成绩,成绩,总分,平均分*/ if(ch=2) /*选择2*/ printf(please input the name: n); /*显示请输

23、入姓名*/scanf(%s,name); /*输入姓名*/ for(i=0;in;i+) if(strcmp(name,studenti.name)=0)/*比较输入的姓名是否符合*/ printf(%st%st%ct%dt%dt%dt%ft%fn,studenti.num,studenti.name,studenti.sex, studenti.score0,studenti.score1,studenti.score2,studenti.sum,studenti.ave); /*输出学生的学号,姓名,性别,成绩,成绩,成绩,总分,平均分*/ fclose(fp); /*关闭文件*/dele

24、te() /*删除*/FILE *fp; /*定义指针文件*/ int i,j,k; char ch1,ch2;char num10,name10; if(fp=fopen(stu.dat,rb)=NULL) /*若文件打不开*/printf(cannot open the file!n);/*显示cannot open the file */ exit(0); /*退出*/ n=0;while(fread(&studentn,sizeof(struct stu),1,fp)=1) n+; printf(please input the students information:n); /*显

25、示请输入学生的信息*/ printf(tt 1=numt2=namen); /*1为学号,2为姓名*/ scanf( %c,&ch1); /*选择*/ f(ch1=1) /*选择1*/ printf(please input the students num=n); /*请输入学生的学号*/ scanf(%s,num); /*输入学生的学号*/ for(i=0;in;i+) if(strcmp(num,studenti.num)=0) /*若um,studenti.num相等*/ printf(%st%st%ct%dt%dt%dt%ft%ftn, studenti.num,studenti.n

26、ame,studenti.sex,studenti.score0, studenti.score1,studenti.score2,studenti.sum,studenti.ave);/*输出学生的学号,姓名,性别,成绩,成绩,成绩,总分,平均分*/ k=i; /*用k标记i的地址*/ if(ch1=2) /*选择2*/printf(please input the students name=n); /*显示请输入学生的姓名*/ canf(%s,name); /*输入姓名*/ or(i=0;in;i+)if(strcmp(name,studenti.name)=0) /*若name,stu

27、denti.name符合*/printf(%st%st%ct%dt%dt%dt%ft%fn,studenti.num,studenti.name,studenti.score0,studenti.score0,studenti.score2,studenti.sum,studenti.ave); /*输出学生的学号,姓名,性别,成绩,成绩,成绩,总分,平均分*/ break;printf(n delete this student Y/N?); /*显示 是否删除该学生*/scanf( %c,&ch2);if(ch2=y|ch2=Y) /*Y y 都可以.是个或逻辑结构*/for(i=i+1;in;i+) udenti-1=studenti; fclose(fp); /*关闭文件*/if(fp=fopen(stu.dat,wb)=NULL) /*若文件打不开*/printf(Cannot open the file!n);exit(0); /*显示cannot open the file 并退出*/for(i=0;in-1;i+) if(ik) fwrite(&studenti,sizeof(struct stu),1,fp); /*若ik,(k为上面标记i的地址),原样输出 */ lse fwrite(&studenti+1,si

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

当前位置:首页 > 社会民生


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