学生成绩管理系统 (4).doc

上传人:精*** 文档编号:859871 上传时间:2023-09-23 格式:DOC 页数:19 大小:173.47KB
下载 相关 举报
学生成绩管理系统 (4).doc_第1页
第1页 / 共19页
学生成绩管理系统 (4).doc_第2页
第2页 / 共19页
学生成绩管理系统 (4).doc_第3页
第3页 / 共19页
学生成绩管理系统 (4).doc_第4页
第4页 / 共19页
学生成绩管理系统 (4).doc_第5页
第5页 / 共19页
点击查看更多>>
资源描述

1、一、课程设计目的1.学会将知识应用于实际的方法,提高分析和解决问题的能力,增加综合能力。2.为后续各门计算机课程的学习打下坚实基础,为毕业设计和以后工作打下必要基础。3.熟悉C语言程序的编辑、编译链接和运行的过程,至少能够用一种编译器较熟练地编辑、编译及调试程序。4.掌握C语言数据类型,如何定义一个整型、字符型和实型的变量,以及对它们赋值的方法。5.学习并掌握C语言定义函数的基本方法、声明函数及调用函数的方法和过程。6. 掌握文件和文件指针的概念以及文件的定义方法,认识文件打开、关闭、读、写等文件基本操作函数。7.了解指针和链表的概念,掌握指针的定义和使用指针变量的方法以及链表的正确用法。灵活

2、使用链表来储存学生信息。二、课程设计内容1.能够对学生的学号,姓名,各科成绩进行统计,并计算出平均分。2.能分别按照学号系、姓名进行查询学生信息。3.能按学号、平均分高低进行排序并输出。4.能够添加、删除和更改学生的信息。开发工具Visual C+ 6.0运行平台Windows XP三、需求分析系统功能及性能的描述:密码模块:用户需要输入密码进行登录。输入模块:.能够对学生的学号,姓名,各科成绩进行输入并输出,同时计算出平均分。查找模块:.能分别按照学号、姓名进行查询学生信息。删除模块:能够根据学生学号进行删除信息。添加模块:可以添加学生信息并保存输出。排序模块:能按学号、各科成绩高低、总分和

3、平均分高低进行排序并输出。文件保存模块:.可以保存到文件(附加功能)。菜单模块:.以菜单方式工作。四、概要设计(1)系统结构图(功能模块图) 主模块 建立学生信息查询学生信息添加学生信息学生信息排序各函数菜单按学号查找学生信息打印学生信息退出系统删除学生信息按姓名查找学生信息按学号升序排序按平均成绩降序排序(2)功能模块说明1.各模块间通过菜单切换和调用2.主函数通过调用菜单函数实现对各功能模块的调用,各功能模块间根据需要可相互调用。3.程序能够保证各模块功能的独立和数据共享。4.相近功能以级联菜单的形式集成。五、详细设计及运行结果流程图, 函数之间相互调用的图示 ,程序设计及编码, 运行结果

4、。开 始输密码判断主函数创建函数添加函数插入函数.删除函数查找函数学号查找姓名查找排序函数退出系统录入函数保存函数信息显示正确错误学号升序平均分降序输出函数菜单函数输出查找结果退出 六、调试情况,设计技巧及体会进入系统后的主菜单:1总体过程编译和调试工具:选择Visual C+6.0,该工具稳定,其中有一个强大的调试工具,我比较熟悉。2 感受心得在两周的时间里,不断地对程序及各模块进行修改、编译、调试,其间遇到很多问题,最终还是被耐心的解决了。两个星期的程序设计,让我认识到学习C语言一定要有耐心,也要细心地对待每一个问题,即使很小的一个错误也可能造成严重的后果。同时也要在平时多积累经验,积累方

5、法,才能使编写的程序更清晰,更简单。七、参考文献1.C语言程序设计 王曙燕 曹锰 王春梅等 科学出版社 2005年2月2.C语言程序设计 谭浩强 清华大学出版社 1999年12八、附录:源代码:/*头文件*/#include #include #include #define N sizeof(M)struct stulong num;char name20;float score1,score2,score3;float aver;typedef struct s_typestruct stu student ;struct s_type *next;M;/*各函数的声明*/void log

6、in();void menu();void createlist(struct s_type *w);float averege( float a,float b,float c);void output(struct s_type *w);void search_num(struct s_type *w);void search_name(struct s_type *w);void del(struct s_type *w);void insert(struct s_type *w);void sort_score(struct s_type *w);void sort_num(struc

7、t s_type *w);/*文件的打开、创建函数*/struct s_type *read_inf()FILE *fp;fp=fopen(c:Softgrade.txt,wt+);if(fp=fopen(c:Softgrade.txt,wt+)=NULL)printf(读文件出错!);getch();exit(1);/*文件的保存函数*/void save(struct s_type *w)struct s_type *p1;FILE *fp;fp=fopen(c:Softgrade.txt,wt+);if(fp=NULL)printf(Error!press any key to retu

8、rn.n);getch();exit(1);for(p1=w-next;p1!=NULL;p1=p1-next)fwrite(p1,N,1,fp);fp=fopen(d:grade.txt,wt+);for(p1=w-next;p1!=NULL;p1=p1-next)fread(p1,N,1,fp);fclose(fp);/*登陆密码*/void login()char mi;char s7;int i,j,t;for(t=1;t=3;t+)printf(密码:);for(i=0;inext=NULL;p2=w; /*将申请到的空间作为头指针*/while(!feof(fp) /*循环读数据直

9、到文件尾结束*/p1=(M *)malloc(N);fread(p1,N,1,fp);p2-next=p1;if(!feof(fp)p2=p1;free(p1);p2-next=NULL;fclose(fp);return(w);/*创建学生信息列表*/void create(struct s_type *w)struct s_type *p,*q;long n;char choice,a20;float r,s,t;if(*w) *w=NULL;printf(n请输入学生信息:n);printf(n 学号: );scanf(%ld,&n);printf(n 姓名: );scanf(%s,a)

10、;printf(n 语文成绩: );scanf(%f,&r);printf(n 数学成绩: );scanf(%f,&s);printf(n 英语成绩: );scanf(%f,&t);p=(M *)malloc(N);p-student.num=n;strcpy(p-student.name,a);p-student.score1=r;p-student.score2=s;p-student.score3=t;p-student.aver=averege(r,s,t);p-next=NULL;*w=p;while(1)printf(n 学号: );scanf(%ld,&n);printf(n 姓

11、名: );scanf(%s,a);printf(n 语文成绩: );scanf(%f,&r);printf(n 数学成绩: );scanf(%f,&s);printf(n 英语成绩: );scanf(%f,&t);q=p;p=(M *)malloc(N);p-student.num=n;strcpy(p-student.name,a);p-student.score1=r;p-student.score2=s;p-student.score3=t;p-student.aver=averege(r,s,t);p-next=NULL;q-next=p;printf(还要继续输入吗?(Yes or

12、No): );flushall();scanf(%c,&choice);if(choice=n|choice=N) break;float averege(float a,float b,float c)float aver;aver=(a+b+c)/3;return aver;/*根据学号查找学生信息*/void search_num(struct s_type *w)long x;printf(请输入要查询的学生信息的学生学号:nn);scanf(%ld,&x);printf(n您查找的学生信息如下:nn); while(w&w-student.num!=x) w=w-next;if(w=

13、NULL)printf(nn*Error,no such student!*n);elseprintf(%ld %s %.2f %.2f %.2f %.2fn,w-student.num,w-student.name,w-student.score1,w-student.score2,w-student.score3,w-student.aver);/*根据姓名查找学生信息*/void search_name(struct s_type *w) char m20;printf(n请输入要查询的学生信息的学生姓名:n);scanf(%s,m);printf(n您查找的学生信息如下:nn);whi

14、le(w&strcmp(w-student.name,m)w=w-next;if(w=NULL)printf(nn*Error,no such student!*n);elseprintf(%ld %s %.2f %.2f %.2f %.2fn,w-student.num,w-student.name,w-student.score1,w-student.score2,w-student.score3,w-student.aver);/*根据学号删除学生信息*/void del(struct s_type *w) long k;struct s_type *p=*w,*t;printf(n请输

15、入要删除的学生信息的学生学号:n);scanf(%ld,&k);if(p-student.num=k)*w=(*w)-next,free(p);elsewhile(p-next&p-next-student.num!=k)p=p-next;if(p-next=NULL)printf(*Error,no such student*!n);elset=p-next;p-next=p-next-next;free(t);/*插入新的学生信息*/void insert(struct s_type *w) long n;char a20;float r,s,t;M *p,*j,*k;printf(n请输

16、入要插入的学生信息:n);printf(n 学号: );scanf(%ld,&n);printf(n 姓名: );scanf(%s,a);printf(n 语文成绩: );scanf(%f,&r);printf(n 数学成绩: );scanf(%f,&s);printf(n 英语成绩: );scanf(%f,&t);p=(M *)malloc(N);p-student.num=n;strcpy(p-student.name,a);p-student.score1=r;p-student.score2=s;p-student.score3=t;p-student.aver=averege(r,s

17、,t);if(!(*w)*w=p;(*w)-next=NULL;return ;if(p-student.numstudent.num)p-next=(*w),(*w)=p;elsej=*w;k=j;while(j-next&j-next-student.numstudent.num)j=j-next;(p-next)=(j-next);j-next=p;*w=k;/*根据学生平均分降序排序*/void sort_score(struct s_type *w) struct s_type *t,*p,*q,*z;if(!(*w)|!(*w)-next)printf(nnn*No message

18、 to sort!*n);return ;elset=*w;p=t-next;t-next=NULL;while(p)q=p-next;if(p-student.avert-student.aver)p-next=t;t=p;else z=t;while(z-next&z-next-student.aver=p-student.aver)z=z-next;p-next=z-next;z-next=p; p=q;*w=t;/*根据学生学号升序排序*/void sort_num(struct s_type *w) struct s_type *t,*p,*q,*z;if(!w)printf(nnn

19、*No message to sort!*n);return ;if(!(*w)|!(*w)-next)return;elset=*w;p=t-next;t-next=NULL;while(p)q=p-next;if(p-student.numstudent.num)p-next=t;t=p;else z=t;while(z-next&z-next-student.numstudent.num)z=z-next;p-next=z-next;z-next=p;p=q;*w=t;/*输出学生信息*/void output(struct s_type *w) if(!w)printf(nnn*No

20、message to output!*n);return ;elsewhile(w)printf(%ldt%st%.2ft%.2ft%.2ft%.2fn,w-student.num,w-student.name,w-student.score1,w-student.score2,w-student.score3,w-student.aver);w=w-next;void menu()printf(nnn *学生成绩管理系统*n);printf(n 1. *建立学生信息表并显示n);printf(n 2. *根据学号查找学生信息n);printf(n 3. *根据姓名查找学生信息n);print

21、f(n 4. *根据学号删除学生信息n);printf(n 5. *添加新的学生信息n);printf(n 6. *按平均分降序排列输出n);printf(n 7. *按学号升序排n);printf(n 8. *打印学生信息数据n);printf(n 0. *退出系统n);printf(n 请选择您所需操作: );main()int i,choose;int flag=1;char name8;struct s_type *w;FILE *fp;w=fp;w=read_inf();printf(nnnnnnn用户名:);flushall();gets(name);printf(n);login

22、();printf(nn欢迎您,%snn,name);printf(请按任意键进入系统!);getch();system(cls);while(flag)system(cls);menu();scanf(%d,&choose);switch(choose)case 1:system(cls);create(&w);system(cls);printf(n请验证您所输入的信息:nn);printf(n学号t姓名t语文t数学t英语t平均成绩n);output(w);printf(nnnPress any key to continue);getch();break;case 2:system(cl

23、s);printf(nn);search_num(w);printf(nnnPress any key to continue);getch();break;case 3:system(cls);printf(nn);search_name(w);printf(nnnPress any key to continue);getch();break;case 4:system(cls);printf(删除前信息库的信息如下:nn);printf(n学号t姓名t语文t数学t英语t平均成绩n);output(w);getch();del(&w);printf(n信息已成功删除,请验证:nn);get

24、ch();printf(删除后的信息库信息如下:nn);printf(n学号t姓名t语文t数学t英语t平均成绩n);output(w);printf(nnnPress any key to continue);getch();break;case 5:system(cls);printf(添加前信息库的信息如下:nn);printf(n学号t姓名t语文t数学t英语t平均成绩n);output(w);getch();insert(&w);printf(信息已成功添加,请验证:nn);getch();printf(添加后信息库的信息如下:nn);printf(n学号t姓名t语文t数学t英语t平均成

25、绩n);output(w);printf(nnnPress any key to continue);getch();break;case 6:system(cls);printf(nn按平均分降序排列输出结果如下:nn);getch();sort_score(&w);printf(n学号t姓名t语文t数学t英语t平均成绩n);output(w);printf(nnnPress any key to continue);getch();break;case 7:system(cls);printf(nn按学号升序排列结果如下:nn);getch();sort_num(&w);printf(n学

26、号t姓名t语文t数学t英语t平均成绩n);output(w);printf(nPress any key to continue);getch();break;case 8:system(cls);printf(nn学生信息如下:n);getch();output(w);printf(nPress any key to continue);getch();break;case 0:system(cls);printf(nnnnnn);flag=0;printf(*n);printf( *n);printf( *nn);printf( You have successfully exit the system.Thank for using!nnnnn);printf( Goodbye!nnnnnnnn);break;default: system(cls);printf(nnnThis is a wrong selection!n);getch();save(w);

展开阅读全文
相关资源
相关搜索
资源标签

当前位置:首页 > 学术论文 > 毕业设计

版权声明:以上文章中所选用的图片及文字来源于网络以及用户投稿,由于未联系到知识产权人或未发现有关知识产权的登记,如有知识产权人并不愿意我们使用,如有侵权请立即联系:2622162128@qq.com ,我们立即下架或删除。

Copyright© 2022-2024 www.wodocx.com ,All Rights Reserved |陕ICP备19002583号-1 

陕公网安备 61072602000132号     违法和不良信息举报:0916-4228922