C++教务管理系统程序报告_第1页
C++教务管理系统程序报告_第2页
C++教务管理系统程序报告_第3页
C++教务管理系统程序报告_第4页
C++教务管理系统程序报告_第5页
已阅读5页,还剩22页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

二○一二~二○一三学年第二学期信息科学与工程学院面向对象C++语言课程设计报告☆课程名称:面向对象C++语言课程设计目录1.需求分析……………………32.总体设计……………………43.详细设计……………………54.调试测验……………………65.测试结果……………………66.心得体会……………………127.相关附录……………………13Ⅰ.需求分析〔1〕问题描述:设计一个学生信息管理系统,能录入、修改、添加、删除、查询、显示学生信息。并将学生信息在文件中保存。〔2〕应用价值:能作为一个有效管理学生信息的系统。可以储存学生的姓名、学号、性别、年龄、住址、各科成绩。这在现实中对学生信息的管理也有极其重要的应用价值。可以有效的保存学生信息,应用于教务管理。〔3〕限制条件:因为刚接触C语言不到,两个学期。所以所做程序难免会有一些瑕疵。在次列举其中的一些限制条件。我所设置的录入学生信息的函数必须由学号由小到大录入,这是为了配合后面的修改、添加、删除查询功能。因为后面几个功能实现的方法就是由学号从小到达找所要修改的那一个结点。另一个问题就是学号的首位不可以为零,否那么的话就无法显示首位。对于这一问题,我还没有想到更好的解决方法。不过在现实应用中,很少出现学号首位为零的情况。因此也就不会太影响使用价值。最后一个问题,就是如果输入的数据类型与定义的不符,就可能引起系统崩溃。因此,用户在录入信息时应特别注意数据类别。Ⅱ总体设计程序设计组成框图1、输入学生的信息:姓名、性别、学号、地址、成绩4、输入要删除的学生的学号,删除学生信息1、输入学生的信息:姓名、性别、学号、地址、成绩4、输入要删除的学生的学号,删除学生信息菜单输入学生信息插入学生信息修改学生信息删除学生信息显示学生信息查询学生信息退出5、显示学生的姓名、性别、学号、地址、成绩2、输入要插入学生的学号,填加信息6、输入你要查找学生姓名或学号,修改学生信息3、按学生的学号或姓名来修改学生的相关信息7、退出系统学生信息管理系统功能模块图流程图开始开始输入学生信息息生生信息修改插入删除查询退出显示结束Ⅲ详细设计函数功能student*creat(void)用于创立链表,不需要参数,返回链表头指针,在输入学生信息时调用。student*del(student*,long)用于删除结点,参数为头指针及要删除学生的学号,返回头指针。在删除学生信息时调用。student*insert(student*,student*)用于插入结点,参数为头指针及类的指针,返回头指针。插入学生信息时调用。student*correct_num(student*,long)用于修改结点,参数为头指针及学号,返回头指针。按学号修改学生信息时调用。student*correct_nam(student*,string)按姓名修改学生信息时调用。student*search_num(student*,long)用于查找结点,参数为头指针及学号,返回头指针。按学号查找学生信息时调用。student*search_nam(student*,string)用于查找结点,参数为头指针及学号,返回头指针。按姓名查找学生信息时调用。intsave(student*head)用于将指针数据存放到文件中。voidprint(student*)参数为头指针,用于输出各结点数据。Ⅳ调试测验通过输入学生信息,再修改、删除、添加、查询,最后输出。检查是否满足预期结果,不满足那么重新完善。过程中也遇到许多问题。其中之一就是在执行查询、添加等功能是出现程序停止工作的情况。最后才发现在进行判断时,将head==NULL误输为head=NULL,将链表转化为了空链表,当然无法工作啦。在其他细节方面,也出现了类似的错误。因此,编程要特别仔细,一个小小的错误,都可能使整个程序毁于一旦。Ⅴ测试结果〔1〕首页〔2〕输入非选项中的的数字〔3〕录入信息〔4〕插入信息〔5〕显示信息〔6〕删除信息〔7〕修改信息〔8〕查询信息〔9〕查询学生学号不存在时〔10〕显示信息〔11〕退出系统Ⅵ心得体会耗时将近两周的C++程序设计即将画上句号。这也是我接触过的最复杂的程序。要想一步完成如此繁琐的程序是不可能的。因此必须有合理的规划,列出框架。再分别用函数来实现各个功能。然后就是细化的工作,要分别设计各个函数,这也是最关键的一步。既要注意各个函数的独立性,又要注意他们之间的关系和在整个程序中的作用。最后将各不分有机结合为宜各整体。再通过不断的调试、完善,最后到达预期的效果。当然,最困难的局部就是修改。面对一个个问题,你需要不断的检查,在繁杂的程序中发现那一个错误。这过程虽然是困难的,必须非常仔细,绞尽脑汁想各种错误的原因,最后解决问题。当问题被解决的那一刻,心中会由然而生出一种成就感。这也是程序设计带给我的快乐。在今后的学习生活中,我将投入更多时间到C++程序设计中,这样设计程序将会更加得心应手。程序设计就是这样一门神奇的课程,只有勤于思考,刻苦钻研,勇于创新才能,才能设计出满意的程序。Ⅶ相关附录#include<iostream>#include<string>#include<stdlib.h>#include<fstream>usingnamespacestd;#defineNULL0classstudent//定义类{public:longnum;charname[20];intage;charsex[20];charaddress[30];floatcomputer_score;floatmath_score;floatEnglish_score;student*next;};intn;//定义主函数intmain(){student*creat(void);student*del(student*,long);student*insert(student*,student*);student*correct_num(student*,long);student*correct_nam(student*,string);student*search_num(student*,long);student*search_nam(student*,string);intsave(student*head);voidprint(student*);student*head=NULL,*stu;longdel_numb,correct_numb,search_numb;intchoose,a;stringsearch_name,correct_name;start:cout<<"***************☆学生信息管理系统☆***************"<<endl;//goto指向的位置cout<<"**********★★★★★★★★★★★★★★★★********"<<endl;cout<<"***************★☆1.输入学生信息☆★***************"<<endl;cout<<"***************★☆2.插入学生信息☆★***************"<<endl;cout<<"***************★☆3.修改学生信息☆★***************"<<endl;cout<<"***************★☆4.删除学生信息☆★***************"<<endl;cout<<"***************★☆5.显示学生信息☆★***************"<<endl;cout<<"***************★☆6.查询学生信息☆★***************"<<endl;cout<<"***************★☆7.退出☆★***************"<<endl;cout<<"请输入您的选择(1--7):"<<endl; cin>>choose;switch(choose)//选择结构,选择要进行的操作{case1:system("cls");//系统清屏cout<<"输入学生信息:"<<endl;head=creat();//调用函数,建立链表 system("cls"); gotostart;//返回目录 break;case2:system("cls");cout<<endl<<"输入要插入的学生信息:";stu=newstudent;//新建结点cout<<"学生的学号:";cin>>stu->num;cout<<"学生的姓名:"; cin>>stu->name; cout<<"学生的年龄:"; cin>>stu->age; cout<<"学生的性别:"; cin>>stu->sex; cout<<"学生的住址:"; cin>>stu->address; cout<<"学生的电脑成绩:"; cin>>stu->computer_score; cout<<"学生的数学成绩:"; cin>>stu->math_score; cout<<"学生的英语成绩:"; cin>>stu->English_score;while(stu->num!=0)//结点学号不为空时插入{head=insert(head,stu);//调用函数,插入结点save(head);//将数据储存在文件中cout<<endl<<"输入要继续插入的学生信息:";stu=newstudent;cout<<"学生的学号:";cin>>stu->num;//输入结点相关信息cout<<"学生的姓名:"; cin>>stu->name; cout<<"学生的年龄:"; cin>>stu->age; cout<<"学生的性别:"; cin>>stu->sex; cout<<"学生的住址:"; cin>>stu->address; cout<<"学生的电脑成绩:"; cin>>stu->computer_score; cout<<"学生的数学成绩:"; cin>>stu->math_score; cout<<"学生的英语成绩:"; cin>>stu->English_score;} system("cls"); gotostart;break;case3:system("cls");cout<<endl<<"输入要修改信息学生的学号/姓"<<endl;cout<<"按学号查询输入1,姓名查询输入"<<endl; cin>>a; if(a==1) {cout<<endl<<"要修改信息学生的学号:"; cin>>correct_numb;head=correct_num(head,correct_numb);//按学号修改学生信息 save(head); } if(a==2) {cout<<endl<<"要修改信息学生的姓名:"; cin>>correct_name; head=correct_nam(head,correct_name);//按姓名修改学生信息 save(head);} system("cls"); gotostart; break; case4:system("cls"); cout<<endl<<"输入要删除学生的学号:"; cin>>del_numb;while(del_numb!=0){head=del(head,del_numb);save(head);cout<<"请输入要继续删除学生的学号:";cin>>del_numb;system("cls"); gotostart;} break; case5:system("cls"); cout<<"学生信息如下:"<<endl;system("cls"); print(head); system("pause");//运行停在当前页面 system("cls"); gotostart;break;case6:system("cls"); cout<<endl<<"输入要查询信息学生的学号/姓名:"<<endl;cout<<"按学号查询输入1,姓名查询输入2:"<<endl; cin>>a; system("cls"); if(a==1) {cout<<endl<<"要查询信息学生的学号:"; cin>>search_numb; head=search_num(head,search_numb);}//调用按学号查询函数if(a==2) {cout<<endl<<"要查询信息学生的姓名:"; cin>>search_name; head=search_nam(head,search_name);}//按姓名查询学生信息 system("pause"); system("cls"); gotostart; break; case7:system("cls"); cout<<"按任意键退出程序!"; exit(0);break;//调用系统函数exit,运行结束 default:cout<<endl<<"请重新选择1--7中的数字!";//输入非选项数字时,返回主菜单 system("pause");system("cls"); gotostart; break; }return0;}//创立链表的函数student*creat(void){ofstreamoutfile("f1.dat",ios::out);//翻开文件if(!outfile){cerr<<"翻开失败"<<endl;exit(0);}student*head;student*p1,*p2;n=0;p1=p2=newstudent;//新建对象cout<<"学生的学号:";cin>>p1->num;outfile<<p1->num<<"";//将数据存入文件cout<<"学生的姓名:";cin>>p1->name;outfile<<p1->name<<"";cout<<"学生的年龄:";cin>>p1->age;outfile<<p1->age<<"";cout<<"学生的性别:";cin>>p1->sex;outfile<<p1->sex<<"";cout<<"学生的住址:";cin>>p1->address;outfile<<p1->address<<"";cout<<"学生的电脑成绩:";cin>>p1->computer_score;outfile<<p1->computer_score<<"";cout<<"学生的数学成绩:";cin>>p1->math_score;outfile<<p1->math_score<<"";cout<<"学生的英语成绩:";cin>>p1->English_score;outfile<<p1->English_score<<"";head=NULL;while(p1->num!=0){n=n+1;if(n==1)head=p1;elsep2->next=p1;//p1指向下一个结点p2=p1;p1=newstudent;cout<<"学生的学号:";cin>>p1->num;outfile<<p1->num<<"";cout<<"学生的姓名:";cin>>p1->name;outfile<<p1->name<<"";cout<<"学生的年龄:";cin>>p1->age;outfile<<p1->age<<"";cout<<"学生的性别:";cin>>p1->sex;outfile<<p1->sex<<"";cout<<"学生的住址:";cin>>p1->address;outfile<<p1->address<<"";cout<<"学生的电脑成绩:";cin>>p1->computer_score;outfile<<p1->computer_score<<"";cout<<"学生的数学成绩:";cin>>p1->math_score;outfile<<p1->math_score<<"";cout<<"学生的英语成绩:";cin>>p1->English_score;outfile<<p1->English_score<<"";}p2->next=NULL; outfile.close();//关闭文件return(head);}//保存文件的函数intsave(student*head){ofstreamoutfile("f1.dat",ios::out);if(!outfile){cerr<<"翻开文件出错!"<<endl;exit(0);}student*p1=head,*p2;if(head==NULL){cout<<"列表为空!"<<endl;return0;};do{outfile<<p1->num<<""<<p1->name<<""<<p1->age<<""<<p1->sex<<""<<p1->address<<""<<p1->computer_score<<""<<p1->math_score<<""<<p1->English_score;//将链表数据存入文件p2=p1;p1=p1->next;}while(p2->next!=NULL);outfile.close();return0;}//删除数据的函数student*del(student*head,longnum){student*p1,*p2;if(head==NULL){cout<<"列表为空!"<<endl;return(head);}p1=head;while(num!=p1->num&&p1->next!=NULL)//按学号从小到大查找{p2=p1;p1=p1->next;}if(num==p1->num){if(p1=head)head=p1->next;//如果找到elsep2->next=p1->next;cout<<"删除的学号:"<<num<<endl;n=n-1;}elsecout<<"不能找到此学号的学生:"<<num;return(head);}//插入学生信息的函数student*insert(student*head,student*stud){student*p0,*p1,*p2;p1=head;p0=stud;if(head==NULL){head=p0;p0->next=NULL;}else{while((p0->num>p1->num)&&(p1->next!=NULL)){p2=p1;p1=p1->next;}if(p0->num<=p1->num){if(head==p1)head=p0;//p1学号最小,那么作为头指针elsep2->next=p0;//否那么插入中间p0->next=p1;}else{p1->next=p0;p0->next=NULL;}//如果最大,那么放在最后}n=n+1;//记录结点数return(head);}//按学号修改学生信息的函数student*correct_num(student*head,longnum){student*p;if(head==NULL){cout<<"列表为空!"<<endl;return(head);}p=head;while(num!=p->num&&p->next!=NULL){p=p->next;}if(num==p->num)//遭到后重新录入学生的信息{cout<<"学生的学号:";cin>>p->num;cout<<"学生的姓名:";cin>>p->name;cout<<"学生的年龄:";cin>>p->age;cout<<"学生的性别:";cin>>p->sex;cout<<"学生的住址:";cin>>p->address;cout<<"学生的电脑成绩:";cin>>p->computer_score;cout<<"学生的数学成绩:";cin>>p->math_score;cout<<"学生的英语成绩:";cin>>p->English_score;}elsecout<<"不能找到此学号的学生:"<<num; return(head);}//按姓名修改学生信息的函数student*correct_nam(student*head,stringname){student*p;if(head==NULL){cout<<"列表为空!"<<endl;return(head);}p=head;while(name!=p->name&&p->next!=NULL){p=p->next;}if(p->name==name){cout<<endl<<"请重新输入此学生的信息";cout<<"学生的学号:";cin>>p->num;cout<<"学生的姓名:";cin>>p->name;cout<<"学生的年龄:";cin>>p->age;cout<<"学生的性别:";cin>>p->sex;cout<<"学生的住址:";cin>>p->address;cout<<"学生的电脑成绩:";cin>>p->computer_score;cout<<"学生的数学成绩:";cin>>p->math_score;cout<<"学生的英语成绩:";cin>>p->English_score;}elsecout<<"不能找到此学号的学生:"<<name;return(head);}//按学号查询学生信息的函数student*search_num(student*head,longnum){student*p;if(head==NULL){cout<<"列表为空!"<<endl;return(head);}p=head;while(num!=p->num&&p->next!=NULL)p=p->next;if(num==p->num)//找到后输出学生信息{cout<<"学生的学号:";cout<<p->num<<endl;cout<<"学生的姓名:"; cout<<p->name<<endl; cout<<"学生的年龄:"; cout<<p->age<<endl; cout<<"学生的性别:"; cout<<p->sex<<endl; cout<<"学生的住址:"; cout<<p->address<<endl; cout<<"学生的电脑成绩:"; cout<<p->computer_score<<endl; cout<<"学生的数学成绩:"; cout<<p->math_score<<endl; cout<<"学生的英语成绩:"; cout<<p->English_score<<endl;} elsecout<<"不能找到此学号的学生:"<<num;return(head);}/

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论