版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、.C语言课程设计报告题 目 学生成绩管理系统 学 院_计算机学院_专 业_计算机科学与技术_年级班别_09级计科一班_学 号_ 3109005882 _学生姓名_黄杰 _指导教师_谢光强_ 成 绩 程序功能完成情况测试用例全面情况报告格式是否与要求相符报告内容是否准确全面2010年 1 月 设计一个学生成绩管理系统,对上学期的本班的学习成绩进行管理,具有查询和检索功能,并且能够对指定文件操作,也可将多个文件组成一个文件。A、 设计内容1、每一条记录包括一个学生的学号、姓名、性别、各门课成绩(上学期的科目)、平均成绩。2、输入功能:可以一次完成若干条记录的输入。3、显示功能:完成全部学生记录的显
2、示。4、查找功能:完成按姓名或学号查找学生记录,并显示。5、排序功能:按学生平均成绩进行排序。6、插入功能:按学号顺序插入一条学生记录。7、将学生记录存在文件student.dat中。8、应提供一个界面来调用各个功能,调用界面和各个功能的操作界面应尽可能清晰美观!B、 设计要求一、 已知有存储本班学生记录(包括学号、姓名、科目成绩、性别、)的文件student.dat,所有学生以学号从小到大排序(该文件自行建立)。要求编程序实现查询、排序、插入、删除诸功能。具体要求如下:A要求显示如下界面*1-查询2-排序3-插入4-删除*通过选择1-4来确定要做哪一个操作。B若选1,则出现如下界面*1.1-
3、按学号查询1.2-按姓名查询1.3-按成绩查询*通过选择1.1-1.3来确定要做哪一个操作,其中:按姓名查询用顺序法实现;按成绩查询实现查询成绩小于m分的学生;找到该生将学生记录输出到屏幕,若查无此人,输出相关信息。C若选2,则按成绩从大到小排序,姓名,学号顺序也随之调整。D若选3,将一个新学生记录按学号顺序插入,并把结果保存到文件student.dat中。E若选4,删除指定学生的记录,并把结果保存到文件student.dat中。G不同的模块都要有出错处理,并能给出出错提示。如输入数据错误,文件操作错误等等F以上各个功能均编写成子函数,由主函数调用实现。G利用结构体数组实现学生成绩的数据结构设
4、计;模块:学生成绩管理系统查询模块排序模块显示模块保存模块删除模块插入模块结束显示返回插入返回选择返回保存返回按学号查询按学号选择删除按姓名选择删除返回主菜单按姓名查询按成绩查询排序返回数学平均分英语C语言健康教育返回计算机历史程序结构图:main: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 '
5、;3':head=NULL?head=insert(head):insert(head); save(head); break;case '4':head=delete(head);save(head);break;case '5':save(head);printf("It's saved!");getch();break;case '6': clrscr();formhead();print(head);break;while(flag)frees(head);int menu();char ch;text
6、mode(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,12); cprintf("3-Insert;&
7、quot;);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:&qu
8、ot;);ch=getchar();return ch;int menu2();char ch;textmode(C80);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;&q
9、uot;);gotoxy(25,14); cprintf("3-search by score;");gotoxy(25,16); cprintf("0-Return to main menu;");gotoxy(20,20); cprintf("*");gotoxy(1,25); cprintf("please press the number you choose:");ch=getchar();return ch;int menu3();char ch;textmode(C80);textbackground
10、(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(25,9); cprintf("2-English;");gotoxy(25,10); cprintf("3-C Program;");gotoxy(25,
11、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); cp
12、rintf("please press the number you choose:");ch=getchar();return ch;void 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
13、*p;int none=1;char number11;p=head;clrscr();printf("please in put a student's number:");scanf("%s",number); 直到确认printf("Search results:n");formhead(); while(p!=0)NY (strcmp(p->num,number)=0?putout(p);none=0;p=p->next;NY None=0?printf("ncan not find the da
14、ta!") printf("npress any key to return.");getch();void search2(struct student *);int none=1; char name11;struct student *p;p=head;clrscr();printf("please in put a student's name:");scanf("%s",name); 直到确认clrscr();printf("Search results:n");formhead();
15、while(p!=NULL)NY strcmp(p->name,name)=0?putout(p);none=0;p=p->next;YNnone=0?printf("ncan not find the data!");printf("npress any key to return."); getch();void search3(struct student *);p1=head;m=menu3() 直到0<=m<=6clrscr();printf("Please enter a highest score:n&qu
16、ot;);scanf("%f",&high); 直到确认clrscr();printf("Search results:n");formhead(); switch(m)1while(p1!=0)NYp1->math-high<0.0?putout(p1); none=0;p1=p1->next;YNNone=0?printf("ncan not find the data!")printf("npress any key to return.");getch();break;2与1同理3
17、与1同理4与1同理5与1同理6与1同理7与1同理struct student *sort(struct student *);struct student *p1,*p2,*t,*temp;temp=head->next; head->next=NULL;while(temp!=NULL)t=temp; temp=temp->next; p1=head; p2=head; while(t->aver<p1->aver&&p1!=NULL)p2=p1; p1=p1->next;NYp1=p2?t->next=p1;t->nex
18、t=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(); /*建链表*/q=findw(head); /*找出传进来链表的表尾*/NYq=NULL?q->next=p;return hed=NULL?p:hed;void input(struct stud
19、ent *);float temp; char c; clrscr();printf("input the student's number:");scanf("%s",p->num); 直到确认printf("ninput the student's name:"); scanf("%s",p->name);while(!sure(); 直到确认c=getchar();p->sex=c>'a'?c-32:c; 直到(p->sex='M'
20、|p->sex='W')printf("input the student's Math score:scanf("%f",&temp); 直到确认p->math=temp;下面成绩同理void 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->eng
21、lish,p->cp,p->computer,p->hthy,p->history,p->aver);printf("n+-+-+-+-+-+-+-+-+-+-+");void print(struct student *);struct student *p;p=head;YNp!=NULLputout(p);p=p->next;printf("It's a empty list!n"); 直到p为空getch();int sure();har c; getchar();printf("Press
22、any key if you are sure but 'Esc':");c=getch();YNc=27return 1;return 0;void frees( struct student *);struct student *p;p=head;while(p!=0)free(p);p=p->next;head=NULL;struct student *creat(void);char c; struct student *p1,*p2,*head; int n=0,flag=1;p1=p2=(struct student *)malloc(LEN); h
23、ead=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();YN(c='N'|c='n'|c='Y'|c='y')?flag=2;
24、NYc='Y'|c='y'?flag=0;p1=(struct student *)malloc(sizeof(struct student);input(p1);flag=1;p2->next=NULL;return (head);struct student *load(void);struct student *p1,*p2,*head=NULL;FILE *fp;YNfp=fopen("student.dat","rb")=NULLprintf("fail to open the file!n&qu
25、ot;);return (0);printf("loading.n");p1=(struct student *)malloc(LEN);YN!p1?printf("out of memory!ngetch();return(0);head=p1while(!feof(fp)NYfread(p1,LEN,1,fp)!=1?break;p1->next=(struct student *)malloc(LEN);NY!p1->next/printf("Out of memory!n");return (head);p2=p1; p1=
26、p1->next;p2->next=NULL; fclose(fp);return (head);void save(struct student *);FILE *fp; struct student *p;Nfp=fopen("student.dat","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);struct
27、student *findw(struct student *);struct student *p;p=head;Np=NULL? Yreturn p;while(p->next!=NULL)p=p->next; return (p);struct student *delete(struct student *);char del11; char x; int none=1; struct student *p1,*_del;p1=_del=head;Np1=NULL? Yclrscr();printf("there is no data!press any key
28、to back.");getch();return 0;clrscr();printf("nnnnnnnnnnnn 1-By Student Number to delete;");printf("nn 2-By Student Name to delete;");printf("nn 0-cancel;n");printf("nnnnnnnnnPlease enter you choice:"); x=getchar(); 直到输入正确if(x='0') return head;if(x
29、='1')clrscr();printf("enter number gonna Del:");scanf("%s",del); 直到确认while(_del=p1&&_del!=NULL)N(strcmp(_del->num,del)=0) Yelse _del=p1->next;none=0; clrscr();printf("delete this data? Cancel by 'Esc:'")formhead();putout(_del);Ngetch()=27 Y
30、p1=_del->next;_del=p1->next;free(_del);del=p1;printf("nDelete successfully!");getch();head=p1;while(_del!=0)Nstrcmp(_del->num,del)=0 Yp1=p1->next;_del=_del->next;none=0; clrscr();printf("ndelete this data? Cancel by 'Esc':");formhead();putout(_del);Ngetch()
31、=27? Yp1->next=_del->next; p1=p1->next;free(_del);_del=_del->next;_del=p1->next; printf("nDelete successfully!");getch();N!none? Yprintf("Can not find the data.");printf("nNo more data.");getch();getch();if(x='2') 同x=1程序代码:course.h#define LEN size
32、of(struct student)#define NULL 0struct student char num11; char name11; char sex; float math; float english; float cp; float computer; float hthy; float history; float aver; struct student *next;int menu();int menu2();int menu3();void search();void search1(struct student *);void search2(struct stude
33、nt *);void search3(struct student *);struct student *sort(struct student *);struct student *insert(struct student *);void input(struct student *);void putout(struct student *);void print(struct student *);int sure();void frees( struct student *);struct student *creat(void);struct student *load(void)
34、;void save(struct student *);struct student *findw(struct student *);struct student *delete(struct student *);/*主菜单函数*/#include<stdio.h>#include<conio.h>int menu() char ch; textmode(C80); textbackground(BLUE); textcolor(YELLOW); clrscr(); gotoxy(20,3); cprintf("Students' perform
35、ance management system"); gotoxy(20,6); cprintf("*"); gotoxy(30,8); cprintf("1-Search;"); gotoxy(30,10); cprintf("2-Sort;"); gotoxy(30,12); cprintf("3-Insert;"); gotoxy(30,14); cprintf("4-Delete;"); gotoxy(30,16); cprintf("5-Save in file;&q
36、uot;); 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;/*查询菜单函数*/#include<stdio.h>#include <stdlib.h>#includ
37、e<conio.h>int menu2()char ch; textmode(C80); 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;")
38、; gotoxy(25,14); cprintf("3-search by score;"); gotoxy(25,16); cprintf("0-Return to main menu;"); gotoxy(20,20); cprintf("*"); gotoxy(1,25); cprintf("please press the number you choose:"); ch=getchar(); return ch;/*按各科成绩查询的菜单界面函数 */#include<stdio.h>#incl
39、ude<conio.h>int menu3() char ch; textmode(C80); textbackground(BLUE); textcolor(YELLOW); clrscr(); gotoxy(20,3); cprintf("Enter the number of subjects to check"); gotoxy(20,6); cprintf("*"); gotoxy(25,8); cprintf("1-Math;"); gotoxy(25,9); cprintf("2-English;&
40、quot;); 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
41、 previous menu;"); gotoxy(20,18); cprintf("*"); gotoxy(1,25); cprintf("please press the number you choose:"); ch=getchar(); return ch;#include<stdio.h>#include"course.h"void search(struct student *head)/*查询界面控制函数*/int flag=1; while(flag) switch(menu2() case 4
42、9:search1(head);break; case 50:search2(head);break; case 51:search3(head);break; case 48:flag=0;break; #include<stdio.h>#include<string.h>#include"course.h"void search1(struct student *head) /*按学号搜索的函数*/ struct student *p; int none=1; char number11; p=head; do clrscr(); printf(
43、"please in put a student's number:"); scanf("%s",number);while(!sure(); clrscr();printf("Search results:n");formhead(); while(p!=0) if(strcmp(p->num,number)=0) putout(p); none=0; p=p->next; /*没有一搜到就停止虽然浪费时间,但可以让用户发现学号重复的错误以便删除*/if(none) printf("ncan not f
44、ind the data!");printf("npress any key to return.");getch();#include<stdio.h>#include<string.h>#include"course.h"void search2(struct student *head)/*按姓名查找的函数*/ int none=1; char name11; struct student *p; p=head; do clrscr(); printf("please in put a student
45、39;s name:"); scanf("%s",name);while(!sure(); clrscr();printf("Search results:n");formhead(); while(p!=NULL) if(strcmp(p->name,name)=0) putout(p); none=0; p=p->next; if(none) printf("ncan not find the data!");printf("npress any key to return.");getc
46、h();#include<stdio.h>#include"course.h"void search3(struct student *head) /*查找低于制定分数的学生的函数,可以分科查找*/struct student *p1=NULL; int m; int none=1; float high; /*if(head->math-0.0)>1.0e-6&&(head->math-100.0)>1.0e-6);*/ p1=head; do m=menu3();while(m<'0'|m>
47、'7'); if(m='0') return; do clrscr(); printf("Please enter a highest score:n"); scanf("%f",&high); while(!sure(); clrscr(); printf("Search results:n"); formhead(); /*输出表格头*/ switch(m) /*按界面函数返回的值输出相应的结果*/ case '1': /*数学*/ while(p1!=0) if(p1-&g
48、t;math-high<0.0) putout(p1); none=0; p1=p1->next; if(none) printf("ncan not find the data!"); printf("npress any key to return."); getch(); break; case '2': /*英语*/ while(p1!=0) if(p1->english-high<0.0) putout(p1); none=0; p1=p1->next; if(none) printf("ncan not find the data!"); printf("npress any key to return."); getch(); break; case '3': /*C语言*/ while(p1!=0) if(p1->cp-high<0.0) putout(p1); none=0; p1=p1->next; if(none) printf("ncan not find the data!"); printf("npress any key to r
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 企业信用管理经验分享会
- 通信线路维护员聘用合同
- 证券交易违规行为处罚办法
- 食品饮料行业设施管理准则
- 2025版山皮石石材电商平台合作框架协议3篇
- 2024年能源行业担保责任与节能减排合同3篇
- 药房环境保护措施
- 2024年装饰公司员工离职与补偿合同范本3篇
- 2025年度住宅小区窗帘清洗与保养服务合同3篇
- 网络直播反三违内容监管
- 小学信息科技《数据与编码-探索生活中的“编码”》教学设计
- 工程款代扣代付款协议书(2篇)
- 2024年湖北省高考化学试卷真题(含答案解析)
- 物业充电桩合作加盟协议书范文
- 2023春国开会计实务专题形考任务4题库1及答案
- 现有民办学校选择登记为营利性民办学校办理流程
- 机械工安全操作规程有哪些(11篇)
- 期末测试卷(一)(试题)2023-2024学年二年级上册数学苏教版
- 2024中国华电集团限公司校招+社招高频难、易错点500题模拟试题附带答案详解
- 国家开放大学电大《会计信息系统》期末终考题库及标准参考答案
- 【飞科电器公司基于杜邦分析法的财务分析案例(7700字论文)】
评论
0/150
提交评论