C语言学生成绩管理系统课程设计报告.docx
《C语言学生成绩管理系统课程设计报告.docx》由会员分享,可在线阅读,更多相关《C语言学生成绩管理系统课程设计报告.docx(34页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、1设计一个学生成绩管理系统,对上学期的本班的学习成绩进行管理,具有查询和检索功能,并且能够对指定文件操作,也可将多个文件组成一个文件。A、设计内容1、每一条记录包括一个学生的学号、姓名、性别、各门课成绩(上学期的科目)、平均成绩。2、输入功能:可以一次完成若干条记录的输入。3、显示功能:完成全部学生记录的显示。4、查找功能:完成按姓名或学号查找学生记录,并显示。5、排序功能:按学生平均成绩进行排序。6、插入功能:按学号顺序插入一条学生记录。7、将学生记录存在文件student.dat中。8、应提供一个界面来调用各个功能,调用界面和各个功能的操作界面应尽可能清晰美观!B、设计要求一、已知有存储本
2、班学生记录(包括学号、姓名、科目成绩、性别、)的文件 student.dat,所有学生以学号从小到大排序(该文件自行建立)。要求编程序实现查询、排序、插入、删除诸功能。具体要求如下:A要求显示如下界面*21-查询2-排序3-插入4-删除*通过选择 1-4 来确定要做哪一个操作。B若选 1,则出现如下界面*1.1-按学号查询1.2-按姓名查询1.3-按成绩查询*通过选择 1.1-1.3 来确定要做哪一个操作,其中:按姓名查询用顺序法实现;按成绩查询实现查询成绩小于 m 分的学生;找到该生将学生记录输出到屏幕,若查无此人,输出相关信息。C若选 2,则按成绩从大到小排序,姓名,学号顺序也随之调整。D
3、若选 3,将一个新学生记录按学号顺序插入,并把结果保存到文件 student.dat 中。E 若选 4,删除指定学生的记录,并把结果保存到文件 student.dat中。G不同的模块都要有出错处理,并能给出出错提示。如输入数3据错误,文件操作错误等等F以上各个功能均编写成子函数,由主函数调用实现。G利用结构体数组实现学生成绩的数据结构设计;模块:查询模块排序模块显示模块保存模块删除模块插入模块结束显示返回插入返回选择返回保存返回按学号查询按学号选择删除按姓名选择删除返回主菜单按姓名查询按成绩查询排序返回数学平均分英语C语言健康教育返回计算机历史学生成绩管理系统学生成绩管理系统4程序结构图:ma
4、in:int flag=1;struct student*head=NULL;head=load();Doswitch(menu()case 0:flag=0;break;case 1:search(head);break;case 2:sort(head);break;case 3:head=NULL?head=insert(head):insert(head);save(head);break;case 4:head=delete(head);save(head);break;case 5:save(head);printf(Its saved!);getch();break;case 6
5、:clrscr();formhead();print(head);break;while(flag)frees(head);int menu();char ch;textmode(C80);textbackground(BLUE);textcolor(YELLOW);clrscr();gotoxy(20,3);cprintf(Students performance management system);gotoxy(20,6);cprintf(*);gotoxy(30,8);cprintf(1-Search;);gotoxy(30,10);cprintf(2-Sort;);gotoxy(30
6、,12);cprintf(3-Insert;);gotoxy(30,14);cprintf(4-Delete;);gotoxy(30,16);cprintf(5-Save in file;);gotoxy(30,18);cprintf(6-Display;);gotoxy(30,20);cprintf(0-Exit;);gotoxy(20,22);cprintf(*);gotoxy(1,25);cprintf(please press the number you choose:);ch=getchar();return ch;5int menu2();char ch;textmode(C80
7、);textbackground(BLUE);textcolor(YELLOW);clrscr();gotoxy(34,5);cprintf(Query menu);gotoxy(20,8);cprintf(*);gotoxy(25,10);cprintf(1-search by ID number;);gotoxy(25,12);cprintf(2-search by name;);gotoxy(25,14);cprintf(3-search by score;);gotoxy(25,16);cprintf(0-Return to main menu;);gotoxy(20,20);cpri
8、ntf(*);gotoxy(1,25);cprintf(please press the number you choose:);ch=getchar();return ch;int menu3();char ch;textmode(C80);textbackground(BLUE);textcolor(YELLOW);clrscr();clrscr();gotoxy(20,3);cprintf(Enter the number of subjects to check);gotoxy(20,6);cprintf(*);gotoxy(25,8);cprintf(1-Math;);gotoxy(
9、25,9);cprintf(2-English;);gotoxy(25,10);cprintf(3-C Program;);gotoxy(25,11);cprintf(4-Computer;);gotoxy(25,12);cprintf(5-Health Education;);gotoxy(25,13);cprintf(6-History;);gotoxy(25,14);cprintf(7-average;);gotoxy(25,15);cprintf(0-Return to previous menu;);gotoxy(20,18);cprintf(*);gotoxy(1,25);cpri
10、ntf(please press the number you choose:);ch=getchar();return ch;6void search(struct student*head);int flag=1;while(flag)switch(menu2()case 49:search1(head);break;case 50:search2(head);break;case 51:search3(head);break;case 48:flag=0;break;void search1(struct student*);struct student*p;int none=1;cha
11、r number11;p=head;clrscr();printf(please in put a students number:);scanf(%s,number);直到确认printf(Search results:n);formhead();while(p!=0)(strcmp(p-num,number)=0?putout(p);none=0;p=p-next;None=0?printf(ncan not find the data!)printf(npress any key to return.);getch();void search2(struct student*);int
12、none=1;char name11;struct student*p;p=head;clrscr();printf(please in put a students name:);scanf(%s,name);直到确认clrscr();printf(Search results:n);formhead();while(p!=NULL)strcmp(p-name,name)=0?putout(p);none=0;p=p-next;NYNYNY7none=0?printf(ncan not find the data!);printf(npress any key to return.);get
13、ch();void search3(struct student*);p1=head;m=menu3()直到0=mmath-highnext;None=0?printf(ncan not find thedata!)printf(npress any key to return.);getch();break;2与1同理3与1同理4与1同理5与1同理6与1同理7与1同理NYYNNY8struct student*sort(struct student*);struct student*p1,*p2,*t,*temp;temp=head-next;head-next=NULL;while(tem
14、p!=NULL)t=temp;temp=temp-next;p1=head;p2=head;while(t-averaver&p1!=NULL)p2=p1;p1=p1-next;p1=p2?t-next=p1;t-next=p1;p2-next=t;head=t;p1=head;while(p1!=NULL)p1=p1-next;clrscr();formhead();print(head);return(head);struct student*insert(struct student*);struct student*p,*q,*hed;hed=head;p=creat();/*建链表*
15、/q=findw(head);/*找出传进来链表的表尾*/q=NULL?q-next=p;return hed=NULL?p:hed;void input(struct student*);float temp;char c;clrscr();printf(input the students number:);scanf(%s,p-num);直到确认printf(ninput the students name:);scanf(%s,p-name);while(!sure();直到确认c=getchar();p-sex=ca?c-32:c;直到(p-sex=M|p-sex=W)printf(
16、input the students Math score:scanf(%f,&temp);直到确认p-math=temp;下面成绩同理NYNY9void putout(struct student*);printf(n|%-10s|%-10s|%c|%-6.1f|%-6.1f|%-6.1f|%-6.1f|%-6.1f|%-6.1f|%-6.1f|,p-num,p-name,p-sex,p-math,p-english,p-cp,p-computer,p-hthy,p-history,p-aver);printf(n+-+-+-+-+-+-+-+-+-+-+);void print(struc
17、t student*);struct student*p;p=head;p!=NULLputout(p);p=p-next;printf(Itsaemptylist!n);直到 p 为空getch();int sure();har c;getchar();printf(Press any key if you are sure but Esc:);c=getch();c=27return 1;return 0;void frees(struct student*);struct student*p;p=head;while(p!=0)free(p);p=p-next;head=NULL;str
18、uct student*creat(void);char c;struct student*p1,*p2,*head;int n=0,flag=1;p1=p2=(struct student*)malloc(LEN);head=NULL;input(p1);while(flag)n=n+1;n=1?head=p1:p2-next=p1;p2=p1;if(flag=1)printf(ncontinue or not?(Y/N):);if(flag=2)printf(npress Y(y)or N(n)only:);c=getch();(c=N|c=n|c=Y|c=y)?flag=2;NYNYNY
19、10c=Y|c=y?flag=0;p1=(structstudent*)malloc(sizeof(structstudent);input(p1);flag=1;p2-next=NULL;return(head);struct student*load(void);struct student*p1,*p2,*head=NULL;FILE*fp;fp=fopen(student.dat,rb)=NULLprintf(fail to open the file!n);return(0);printf(loading.n);p1=(struct student*)malloc(LEN);!p1?
20、printf(out of memory!ngetch();return(0);head=p1while(!feof(fp)fread(p1,LEN,1,fp)!=1?break;p1-next=(struct student*)malloc(LEN);!p1-next/printf(Out of memory!n);return(head);p2=p1;p1=p1-next;p2-next=NULL;fclose(fp);return(head);void save(struct student*);FILE*fp;struct student*p;fp=fopen(student.dat,
21、wb)=NULL?Yprintf(fail to open the file!n);getch();return;p=head;while(p!=NULL)fwrite(p,LEN,1,fp);p=p-next;fclose(fp);NYNYNYYNNYN11struct student*findw(struct student*);struct student*p;p=head;p=NULL?Yreturn p;while(p-next!=NULL)p=p-next;return(p);struct student*delete(struct student*);char del11;cha
22、r x;int none=1;struct student*p1,*_del;p1=_del=head;p1=NULL?Yclrscr();printf(there is no data!press any key to back.);getch();return 0;clrscr();printf(nnnnnnnnnnnn1-ByStudent Number to delete;);printf(nn2-By Student Name todelete;);printf(nn0-cancel;n);printf(nnnnnnnnnPlease enter you choice:);x=get
23、char();直到输入正确if(x=0)return head;if(x=1)clrscr();printf(enternumber gonna Del:);scanf(%s,del);直到确认while(_del=p1&_del!=NULL)(strcmp(_del-num,del)=0)Yelse _del=p1-next;none=0;clrscr();printf(delete this data?Cancel by Esc:)formhead();putout(_del);getch()=27Yp1=_del-next;_del=p1-next;free(_del);del=p1;N
24、NNN12printf(nDeletesuccessfully!);getch();head=p1;while(_del!=0)strcmp(_del-num,del)=0Yp1=p1-next;_del=_del-next;none=0;clrscr();printf(ndelete this data?Cancel byEsc:);formhead();putout(_del);getch()=27?Yp1-next=_del-next;p1=p1-next;free(_del);_del=_del-next;_del=p1-next;printf(nDeletesuccessfully!
25、);getch();!none?Yprintf(Can not find the data.);printf(nNo more data.);getch();getch();if(x=2)同 x=1程序代码:#include stdio.h/*标准输入输出函数库*/#include stdlib.h/*标准函数库*/#include string.h/*字符串函数库*/#include conio.h/*屏幕操作函数库*/#define HEADER1-学生-n#define HEADER2|学号|姓名|C 语言|数学|英语|总分|平均分|排名|n#define HEADER3|-|-|-|-
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 语言 学生 成绩管理系统 课程设计 报告
限制150内