




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、面向对象程序设计课程实验报告学生成绩管理系统班级计算机应用091班姓名唐俊驰学号 2009052023日期 2010-12-26需求分析1. 程序的功能:学生数据的录入、添加、修改与删除;成绩统计并排名;学生数据的 读取与存储等基本功能。2. 输入输出的要求:输入学生的成绩及处理要求;输出自己想得到的结果3.测试数据。zha ng123586974wang456789658yang789896859详细设计1. 程序框架设计:设置了添加、修改、删除、查找、排序和对数据的读取、保存等功能。2. 程序详细设计添加:创建一个新的分类,用输入的变量初始化这个类,并用指针链接上一个对象。 修改:先通过链
2、表找到要修改的对象,在输入要修改的值,利用类内函数对值进行 修改。删除:根据输入的条件找到要删除的对象,将此对象的next指针赋值给上一个对象的n ext值。查找:按照学号或者姓名按链表查找对象,找到后输出该对象的基本信息。排序:利用比较法,按照要求的标准进行排序。数据的读取和保存:文件的打开和关闭,并按照存储的格式读取。三、调试分析1. 调试中遇到的问题及对问题的解决方法四、使用说明及测试结果1. 系统配置: Windows XP SP3 ; VC 6.0系统运行效果图|c; *P; C+STUDebugstu. exe*日回田 |&total6 * *"turn choo
3、se<l-6 -1戶.have5message.*j ianstudent1 snumbcrs666 r nath: 57, language : 85 ” enf J.iah = 47 inzhan泸J snumbemath = 58,language :69,english:74(. inwangstudent1snumbei*&45& ,ma七h= ?魁 * language: 96,en$fllsh:ES, inf e if estudcntJ enumbei?s3948 ,natli: 87P lanQfuae : 57, englisli :69 , iyan
4、gstuclent1 snur»bers789,niAt>i = S?,lanquage:68,english:59, inEcore Ey£tei*m二1dd2delete3change| 4"okFofi五、源程序(带注释)1 程序代码/*stu.cpp*/#in clude<iostream>#in elude ".ClassHead.h"using n amespace std;void mai n() char c;cla a;do cout<<"n score systerm:n"c
5、out<<" 1adn"cout<<" 2-delen"cout<<" 3change"cout<<" 4 look ffem"cout<<" 5paiXU'cout<<" 6saVe"cout<<" 7-read"cout<<" 8-back"cout<<"choose(1-8):"cin> >c;
6、switch(c) case '1':a.sadd();break;case '2':a.sremove(); break;case '3':a.samend(); break;case '4':a.ssearch(); break;case '5':a.staxis(); break;case '6':a.ssave(); break;case '7':a.sload(); break;while(c!='8');/* 类的定义及其成员函数的实现 */#ifndef
7、 _CLASSHEAD_H#define _CLASSHEAD_H#include<iomanip>#include<fstream>#include<string>#define max 80;using namespace std;class student public:student *next;public:string name;long num;int x,y,z;int AA; void play() cout << name << "student's numbers" <<
8、num << ",math:" << x<< ",language:" << y << ",english:" << z << ",in total:" << AA << endl; ;student(string sname,long snum,int sx,int sy,int sz) name = sname;num = snum;x = sx;y = sy;z = sz; ;class cla pub
9、lic:cla() stu = 0; sload();cla() student *p; p = stu; while(p) p = p->next; delete stu; stu = p; stu = 0;void sadd(); void sremove();void samend(); void ssearch();void staxis(); void ssave();void sload();void pxh(); void psx(); void pyw(); void pyy();void pAA();private:student *stu; ;void cla:sad
10、d() student *q; string name1; long num1; int x1,y1,z1;system("cls");cout << "n *add student* n" << endl;cout << "please input:" << endl;cout << "nametnumbertmathtlanguagetenglish:" << endl; cin >> name1 >> num1 &
11、gt;> x1 >> y1 >> z1;q = new student(name1,num1,x1,y1,z1);q->next = 0;q->AA = x1 + y1 + z1;if(stu) student *t;t = stu; if(t->num = num1) cout << "number has already been recorded , please input again" << endl; return;while(t->next) if(t->num = num1)
12、 cout << "number has already been recorded , please input again" << endl; return;t = t->next;t->next = q;else stu = q;cout << "down" << endl;void cla:sremove() system("cls"); int num1;cout << "n* delete *n"cout << &quo
13、t;please input the number you want to delete:" cin >> num1;student *p1,*p2;p1 = stu; while(p1) if(p1->num = num1) break;else p2 = p1; p1 = p1->next;if(p1 != NULL) p1->play();cout << "Y/N" << endl;char c;cin >> c; if(toupper(c)!='Y') return;if(p
14、1=stu) stu = p1->next; delete p1;else p2->next = p1->next; delete p1;cout << "find the number is:" << num1 << "deleten" elsecout << "there's no information about that!n"void cla:samend() system("cls"); long num1;cout <&l
15、t; "n* change the student number*n"cout << "input the changing number"cin >> num1;student *p1,*p2;p1 = stu;while(p1) if(p1->num = num1)break;else p2 = p1;p1 = p1->next;if(p1!=NULL) cout << "the number is" << num1 << "'informa
16、tion" << endl;"namecout << "<<p1->name<<"math"<<p1->x<<"language"<<p1->y<<"english"<<p1->z<<endl;cout<<"please the changing information : name math language english"&l
17、t;<endl; cin>>p1->name>>p1->x>>p1->y>>p1->z;p1->AA=p1->x+p1->y+p1->z;cout<<"change suceed"<<endl;elsecout<<"no found!n"void cla:ssearch() system("cls");cout<<"n* look for *n"<<end
18、l;cout<<"please input the way : "<<endl;cout<<"1.number"<<endl;cout<<"2.name"<<endl;cout<<"3.return"<<endl;char c;cin>>c;switch (c) case '1':long num1;cout<<"the number"<<endl;
19、cin>>num1;student *p1,*p2;p1=stu;while(p1) if(p1->num=num1)break;else p2=p1; p1=p1->next;if(p1!=NULL) cout<<"muber is"<<num1<<" information"<<endl; cout<<"name:"<<p1->name<<" math:"<<p1->x<&l
20、t;" english:"<<p1->z<<endl;cout<<"down"else cout<<"no foud!n"break;case '2':string name1;cout<<"the name"<<endl;cin>>name1;student *p1,*p2;p1=stu;while(p1) if(p1->name=name1)break;else p2=p1; p1=p1->ne
21、xt;if(p1!=NULL) cout<<name1<<"information"<<endl; cout<<"number:"<<p1->num<<" math:"<<p1->x<<" english:"<<p1->z<<endl;cout<<"down."elselanguage:"<<p1->y<<&
22、quot;language:"<<p1->y<<"cout<<"no foud!n"break;case '3':return;void cla:pxh() student *p1,*p2;int n;p1=stu;n=1;while(p1->next) n+;p1=p1->next;cout<<"have"<<n<<"message."<<endl; int i;p1=stu;for(i=1;i&
23、lt;n;i+) p1=stu;if (p1->num>p1->next->num) p2=p1->next; p1->next=p1->next->next; p2->next=p1;stu=p2;p1=stu;while(p1->next->next) p2=p1;p1=p1->next;if(p1->num>p1->next->num) p2->next=p1->next; p1->next=p1->next->next; p2->next->next
24、=p1; p1=p2->next;p1=stu;do p1->play();p1=p1->next;while(p1);void cla:psx() student *p1,*p2;int n;p1=stu;n=1;while(p1->next) n+;p1=p1->next;cout<<"have"<<n<<"message."<<endl; int i;p1=stu;for(i=1;i<n;i+) p1=stu;if (p1->x>p1->next-
25、>x) p2=p1->next; p1->next=p1->next->next; p2->next=p1;stu=p2;p1=stu;while(p1->next->next) p2=p1;p1=p1->next; if(p1->x>p1->next->x) p2->next=p1->next; p1->next=p1->next->next; p2->next->next=p1; p1=p2->next;p1=stu;do p1->play();p1=p1-&
26、gt;next;while(p1);void cla:pyw() student *p1,*p2;int n;p1=stu;n=1;while(p1->next) n+;p1=p1->next;cout<<"have"<<n<<"message."<<endl; int i;p1=stu;for(i=1;i<n;i+) p1=stu;if (p1->y>p1->next->y) p2=p1->next; p1->next=p1->next->
27、next; p2->next=p1;stu=p2;p1=stu;while(p1->next->next) p2=p1;p1=p1->next; if(p1->y>p1->next->y) p2->next=p1->next; p1->next=p1->next->next; p2->next->next=p1; p1=p2->next;p1=stu;do p1->play();p1=p1->next;while(p1);void cla:pyy() student *p1,*p2;in
28、t n;p1=stu;n=1;while(p1->next) n+;p1=p1->next;cout<<"have"<<n<<"message."<<endl; int i;p1=stu;for(i=1;i<n;i+) p1=stu;if (p1->z>p1->next->z) p2=p1->next; p1->next=p1->next->next; p2->next=p1;stu=p2;p1=stu;while(p1->nex
29、t->next) p2=p1;p1=p1->next;if(p1->z>p1->next->z) p2->next=p1->next; p1->next=p1->next->next; p2->next->next=p1; p1=p2->next;p1=stu;do p1->play();p1=p1->next;while(p1);void cla:pAA() student *p1,*p2;int n;p1=stu;n=1;while(p1->next) n+;p1=p1->next;
30、cout<<"have"<<n<<"message."<<endl;int i;p1=stu;for(i=1;i<n;i+) p1=stu;if (p1->AA>p1->next->AA) p2=p1->next; p1->next=p1->next->next; p2->next=p1; / 头结点交换 stu=p2;p1=stu;while(p1->next->next) / 中间的交换 p2=p1;p1=p1->next;
31、if(p1->AA>p1->next->AA) p2->next=p1->next; p1->next=p1->next->next; p2->next->next=p1; p1=p2->next; / 交换p1=stu;do p1->play();p1=p1->next;while(p1);void cla:staxis() /排序system("cls");char c;cout<<" 请选择以何种方式排序: "<<endl;cout<&
32、lt;"1 number"<<endl;cout<<"2 math"<<endl;cout<<"3 Ianguage"<<endl;cout<<"4 english"<<endl;cout<<" 5total"<<e ndl;cout<<"6 return"<<endl;cout<<"choose(1-6)"<<endl; cin>>c;switch (c) case '1':pxh(); break;case '2':psx(); break;case '3':pyw(); break;case
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 软件升级及维护合同
- 交通协管员聘用合同协议书
- 家禽购销合同
- 货品抵款结算协议书
- 应对市场变化的解决方案研究
- 兰州房屋租赁合同
- 机械租赁协议合同
- 第19课 治学须有疑无疑不成学-《怀疑与学问》(教学设计)九年级语文上册同步高效课堂(统编版)
- 第一单元学习任务《如何阐述自己的观点》教学设计 2023-2024学年统编版高中语文必修下册
- Unit 4 Fun with numbers 第二课时(教学设计)-2024-2025学年外研版(三起)(2024)英语三年级上册
- 有温度的护理人
- 1《挑战第一次》第1课时 说课稿 -2023-2024学年道德与法治二年级下册统编版
- 预防性试验四措一案及施工方案
- 第十八届“地球小博士”全国地理知识科普竞赛题库(附答案)
- 新人教版一年级数学下册全册教案(表格式)
- 尿碘检测临床意义
- 2022年山东司法警官职业学院单招语文试题及答案解析
- 2023版北京协和医院重症医学科诊疗常规
- 钢网验收报告
- 防水补漏工程合同(合同版本)
- 铁路局中间站管理手册
评论
0/150
提交评论