C++课程设计成绩管理系统.doc

上传人:文库蛋蛋多 文档编号:2384435 上传时间:2023-02-17 格式:DOC 页数:15 大小:104KB
返回 下载 相关 举报
C++课程设计成绩管理系统.doc_第1页
第1页 / 共15页
C++课程设计成绩管理系统.doc_第2页
第2页 / 共15页
C++课程设计成绩管理系统.doc_第3页
第3页 / 共15页
C++课程设计成绩管理系统.doc_第4页
第4页 / 共15页
C++课程设计成绩管理系统.doc_第5页
第5页 / 共15页
点击查看更多>>
资源描述

《C++课程设计成绩管理系统.doc》由会员分享,可在线阅读,更多相关《C++课程设计成绩管理系统.doc(15页珍藏版)》请在三一办公上搜索。

1、C+课程设计报告班级: 计网1003班 学号: 1008040324 姓名: 时间: 2011-7-8 计算机科学与技术学院题目:成绩管理系统 一、设计内容成绩管理系统现有学生成绩信息,内容如下姓名 学号 语文 数学 英语张明明 01 67 78 82李成友 02 78 91 88李灿辉 03 68 82 56王露 04 56 45 77陈东明 05 67 38 47. . . . . . 请用C/C+编写一系统,实现学生信息管理,软件的入口界面应包括如下几个方面:功能要求:(1)信息维护要求:学生信息数据要以文件的形式保存,能实现学生信息数据的维护。此模块包括子模块有:增加学生信息、删除学生

2、信息、修改学生信息(2)信息查询:要求:查询时可实现按姓名查询、按学号查询(3)成绩统计:要求:任意输入一个课程名(如数学)和一个分数段(如60-70),统计出在此分数段的学生情况(4)单科排序:要求:能对用户指定的任意课程名,按成绩升序或降序排列学生数据并显示排序结果(使用表格的形式显示排序后的输出结果)(使用多种方法排序者加分)二、设计目的1. 达到熟练掌握C+语言的基本知识和技能;2. 能够利用所学的基本知识和技能,解决简单的面向对象程序设计问题。3.能够读写程序三、系统分析与设计(确定程序功能模块)1.用cout.cin来实现程序的输入,输出2.用了Statistis()计算平均成绩3

3、.用Lookup()实现查询4用Modifk()实现修改5用Delete()实现删除6用Output()实现输出7用Sort()冒泡实现排序8用Insert()实现插入四、源程序代码#include#include#include#include#includeclass Stu /构建学生类public:friend void Input(Stu stud) ;friend void Statistic(Stu stud);friend void Lookup(Stu stud) ;friend void Modify(Stu stud) ;friend void Delete(Stu st

4、ud) ;friend void Output(Stu stud) ;friend void Sort(Stu stud) ;friend void Insert(Stu stud) ;friend void Write(Stu stud,int n); friend int Read(Stu stud);private:int num;char name8;float chinese; float math;float english;float average;int order;stud100;void Write(Stu stud,int n) /向文件中写入数据fstream myF

5、ile;myFile.open(C:student.txt,ios:out|ios:binary);if(!myFile)coutC:student.txt cant open!endl;abort();int count=n;myFilecountendlendl;for(int i=0;i=count;i+)myFilestudi.num studi.name studi.chinese studi.math studi.english studi.averageendl; myFile.close();int Read(Stu stud) /从文件中读数据 fstream myFile;

6、 myFile.open(C:student.txt,ios:in|ios:binary); if(!myFile)coutC:student.txt cant open!count; for(int i=0;istudi.numstudi.namestudi.chinesestudi.mathstudi.englishstudi.average; myFile.close(); return count ;void Input(Stu stud) /-输入学生成绩system(cls); /*运行前清屏*/int i=0;int flag;char sign;coutendl 请输入学生成绩

7、 =endl;while(sign!=n&sign!=N) /*判断*/ loop:coutstudi.num;int c=0;while(ci)c+;if(studi.num=studi-c.num)cout 你输入的学号已经存在!请重新输入。endl;goto loop;coutstudi.name; doflag=0; coutstudi.chinese; if(studi.chinese100 |studi.chinese1) cout对不起,请输入1-100之间的数字!n; else flag=1;while(flag=0); do flag=0; coutstudi.english

8、; if(studi.english100 |studi.english1) cout对不起,请输入1-100之间的数字!n; else flag=1;while(flag=0); doflag=0;coutstudi.math; if(studi.math100 |studi.math1) cout对不起,请输入1-100之间的数字!n; else flag=1;while(flag=0); studi.average=(studi.chinese+studi.math+studi.english)/3; cout平均分为:studi.averageendl; cout提示:是否继续写入学生

9、成绩?(Y/N); cinsign; /*输入判断*/ i+; Write(stud,i);void Statistic(Stu stud) /-统计学生数据 system(cls); /*运行前清屏*/ int n=Read(stud);coutendl 输出学生统计数据 =endl; out学号t姓名t语文t数学t英语t平均分endl;for(int i=0;in;i+)coutstudi.numtstudi.nametstudi.chinesetstudi.mathtstudi.englishtstudi.averageendl; system(pause); void Lookup(S

10、tu stud) /-查找学生成绩 system(cls); /*运行前清屏*/ int n=Read(stud);int s; int i=0;coutendl 查找学生成绩 =endl;cout请输入需要查找学生的学号:s; while(studi.num-s)!=0&in) i+; /*查找判断*/ if(i=n) cout提示:对不起,无法找到该学生的信息!endl; /*输入失败信息*/ elsecout-endl; cout学号:studi.numendl; /*输出该学生信息*/ cout姓名:studi.nameendl; cout语文:studi.chineseendl; c

11、out数学:studi.mathendl; cout英语:studi.englishendl; cout平均分:studi.averageendl;void Modify(Stu stud) /-修改学生成绩 system(cls); /*运行前清屏*/ int n=Read(stud);int s; int i=0;coutendl 修改学生成绩 =endl;cout请输入需要修改成绩学生的学号:s; while(studi.num-s)!=0&in) i+; /*查找判断*/ if(i=n) cout提示:对不起,无该学生的成绩endl; /*输入失败信息*/ elsecout-该学生的信

12、息-endl; /*格式头*/ cout学号t姓名t语文t数学t英语t平均分endl;cout-endl; coutstudi.numtstudi.nametstudi.chinesetstudi.mathtstudi.englishtstudi.averageendl;cout请重新输入该学生的信息endl;cout学号:studi.num; cout姓名:studi.name; cout语文成绩:studi.chinese; cout数学成绩:studi.math; cout英语成绩:studi.english;studi.average=(studi.chinese+studi.math

13、+studi.english)/3; cout平均分为:studi.averageendl; char c; cout是否保存数据?(y/n)c; if(c!=n&c!=N) Write(stud,n);void Delete(Stu stud) /-按学号查找,删除学生信息 system(cls); /*运行前清屏*/ int n=Read(stud);int s; int i=0,j;coutendl 删除学生成绩 =endl;cout请输入需要删除学生的学号:s; while(studi.num-s)!=0&in) i+; /*查找判断*/ if(i=n) cout提示:对不起,无法找到

14、该学生endl; /*返回失败信息*/ elsefor(j=i;jn-1;j+) /*删除操作*/ strcpy(studj.name,studj+1.name); studj.num=studj+1.num; studj.chinese=studj+1.chinese; studj.math=studj+1.math; studj.english=studj+1.english;studj.average=studj+1.average;cout提示:已成功删除!endl; /*返回成功信息*/ Write(stud,n-1); void Insert(Stu stud) /-增加学生成绩

15、system(cls); /*运行前清屏*/int n=Read(stud);char s;coutendl 增加学生成绩=endl;while(s!=n&s!=N)cout学号:studn.num; coutstudn.name; coutstudn.chinese; coutstudn.math; coutstudn.english; studn.average=(studn.chinese+studn.english+ studn.math)/3; cout平均分studn.average;n+; cout提示:插入成功!endl; /*返回成功信息*/cout是否继续输入(y/n)s;

16、Write(stud,n); void Sort(Stu stud) /-按平均分对学生成绩记录项进行降序排序 system(cls); /*运行前清屏*/ int i,j,k; float s; char t20;coutendl 降序排序成绩 =endl;int n=Read(stud);for(i=0;in-1;i+) /*冒泡法排序*/ for(j=0;jn-1-i;j+) if(studj.averagestudj+1.average) strcpy(t,studj+1.name); strcpy(studj+1.name,studj.name); strcpy(studj.name

17、,t); k=studj+1.num; studj+1.num=studj.num; studj.num=k; s=studj+1.chinese; studj+1.chinese=studj.chinese; studj.chinese=s; s=studj+1.math; studj+1.math=studj.math; studj.math=s; s=studj+1.english; studj+1.english=studj.english; studj.english=s; s=studj+1.average; studj+1.average=studj.average; studj

18、.average=s; cout-endl; /*格式头*/ cout学号t姓名t语文t数学t英语t平均分t名次endl; cout-endl; for(i=0;in;i+) /*循环输入*/ studi.order=i+1;coutstudi.numtstudi.nametstudi.chinesetstudi.matht studi.englishstudn.averagetstudi.orderendl; Write(stud,n);void Output(Stu stud) /-显示全部学生成绩 system(cls); /*运行前清屏*/int n=Read(stud);couten

19、dl 显示全部学生成绩 =endl;if(!stud)cout没有记录; else待添加的隐藏文字内容3cout-endl; /*格式头*/ cout学号t姓名t语文t数学t英语t平均分名次endl;cout-endl; for(int i=0;in;i+) /*循环输入*/ coutstudi.numt studi.namet studi.chinese t studi.math tstudi.englishtstudn.averagetstudi.orderendl; cout-endl; int menu() /*菜单函数*/ char c; do system(cls); /*运行前清

20、屏*/ cout*nendl; cout -欢迎您使用学生成绩管理系统-nendl; cout *nnendl;/*菜单选择*/ cout * 【1】增加学生成绩 * endl; cout * 【2】显示统计数据 * endl; cout * 【3】查找学生成绩 * endl; cout * 【4】修改学生成绩 * endl; cout * 【5】删除学生成绩 * endl; cout * 【6】插入学生成绩 * endl; cout * 【7】按平均分降序排列 * endl; cout * 【8】显示全部学生成绩 * endl; cout * 【0】退出本系统 * endlendl; cou

21、t*endl; cout请你选择操作(0-8):endl; c=getchar(); /*读入选择*/ while(c8); return(c-0); /*返回选择*/ void main() /*主函数*/ for(;) switch(menu() /*选择判断*/ case 1: Input(stud);/*增加学生成绩*/ break; case 2: Statistic(stud); /*输出学生统计数据*/ break; case 3: Lookup(stud); /*查找学生成绩*/ coutttt; system(pause); break; case 4: Modify(stu

22、d); /*修改学生成绩*/ coutttt; system(pause); break; case 5: Delete(stud); /*按学号查找,删除学生信息*/ coutttt; system(pause); break; case 6: Insert(stud);/*插入学生成绩*/ coutttt; system(pause); break; case 7: Sort(stud); /*按平均分对成绩记录项进行降序排序*/ coutttt; system(pause); break; case 8: Output(stud); /*显示全部学生成绩*/ coutttt; system(pause); break; case 0: coutendl =nendl; /*结束程序*/ coutttt; system(pause); exit(0); 五、运行结果及功能说明六.设计体会1.因为我不能熟练的掌握C+知识,但是我通过借鉴,分析,查找,让我进一步了解了C+,本想自己编辑但是还是因为自己知识有限没能成功,最后还是更改了一个课本程序完成了这次实习。2.随然没有完成自己的程序,但我的收获也是很多的,让我知道我今后学习的方向。

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

当前位置:首页 > 建筑/施工/环境 > 项目建议


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号