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

下载本文档

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

文档简介

1、二一二二一三学年第二学期信息科学与工程学院面向对象C+ 语言课程设计报告课程名称:面向对象 C+ 语言课程设计_目录精品资料_1.需求分析2.总体设计3.详细设计 3 4 54.调试测验 65.测试结果 66.心得体会 127.相关附录 13精品资料_.需求分析(1)问题描述 :设计一个学生信息管理系统,能录入、修改、添加、删除、查询、显示学生信息。并将学生信息在文件中保存。( 2)应用价值:能作为一个有效管理学生信息的系统。可以储存学生的姓名、学号、性别、年龄、住址、各科成绩。这在现实中对学生信息的管理也有极其重要的应用价值。可以有效的保存学生信息,应用于教务管理。( 3)限制条件:因为刚接

2、触 C 语言不到,两个学期。所以所做程序难免会有一些瑕疵。在次列举其中的一些限制条件。我所设置的录入学生信息的函数必须由学号由小到大录入,这是为了配合后面的修改、添加、删除查询功能。因为后面几个功能实现的方法就是由学号从小到达找所要修改的那一个结点。另一个问题就是学号的首位不可以为零,否则的话就无法显示首位。对于这一问题,我还没有想到更好的解决方法。不过在现实应用中,很少出现学号首位为零的情况。因此也就不会太影响使用价值。最后一个问题,就是如果输入的数据类型与定义的不符,就可能引起系统崩溃。因此,用户在录入信息时应特别注意数据类别。精品资料_总体设计( 1) 程序设计组成框图功能模块图学生信息

3、管理系统6、输入你要查找学生姓名或学号,修改学生2、输入要插入信息5 、显示学生的姓名、性别、学学生的学号,菜单号、地址、成绩填加信息1.输入学生信息2.插入学生信息3.修改学生信息1、输入学生的信4.删除学生信息5.显示学生信息7 、退出系统息 :姓名、性别、6.查询学生信息学号、地址、成7.退出绩4 、输入要删除的学3、按学生的学号或姓名来修改学生的生的学号, 删除学生相关信息信息精品资料_(2)流程图开始输入学生信息退出修改删除查询插 入显示结束详细设计函数功能student *creat(void)用于创建链表,不需要参数,返回链表头指针,在输入学生信息时调用。student *del

4、(student*,long)用于删除结点,参数为头指针及要删除学生的学号,返回头指针。在删除学生信息时调用。student*insert(student*,student*)用于插入结点,参数为头指针及类的指针,返回头指针。插入学生信息时调用。student*correct_num(student*,long) 用于修改结点,参数为头指针及学号,返回头指针。按学号修改学生信息时调用。student*correct_nam(student*,string) 按姓名修改学生信息时调用。精品资料_student *search_num(student *,long)用于查找结点,参数为头指针及学号

5、,返回头指针。按学号查找学生信息时调用。student*search_nam(student*,string)用于查找结点,参数为头指针及学号,返回头指针。按姓名查找学生信息时调用。int save(student *head)用于将指针数据存放到文件中。void print(student*)参数为头指针,用于输出各结点数据。调试测验通过输入学生信息,再修改、删除、添加、查询,最后输出。检查是否满足预期结果,不满足则重新完善。过程中也遇到许多问题。其中之一就是在执行查询、添加等功能是出现程序停止工作的情况。最后才发现在进行判断时,将head=NULL误输为 head=NULL, 将链表转化为

6、了空链表, 当然无法工作啦。在其他细节方面,也出现了类似的错误。因此,编程要特别仔细,一个小小的错误,都可能使整个程序毁于一旦。测试结果(1)首页精品资料_(2)输入非选项中的的数字(3)录入信息精品资料_(4)插入信息(5)显示信息精品资料_(6)删除信息(7)修改信息精品资料_(8)查询信息(9)查询学生学号不存在时精品资料_(10 )显示信息(11 )退出系统精品资料_心得体会耗时将近两周的 C+ 程序设计即将画上句号。 这也是我接触过的最复杂的程序。 要想一步完成如此繁琐的程序是不可能的。 因此必须有合理的规划, 列出框架。再分别用函数来实现各个功能。然后就是细化的工作, 要分别设计各

7、个函数, 这也是最关键的一步。既要注意各个函数的独立性, 又要注意他们之间的关系和在整个程序中的作用。 最后将各不分有机结合为宜各整体。 再通过不断的调试、完善,最后达到预期的效果。当然,最困难的部分就是修改。面对一个个问题,你需要不断的检查,在繁杂的程序中发现那一个错误。这过程虽然是困难的,必须非常仔细,绞尽脑汁想各种错误的原因,最后解决问题。当问题被解决的那一刻,心中会由然而生出一种成就感。这也是程精品资料_序设计带给我的快乐。在今后的学习生活中,我将投入更多时间到 C+ 程序设计中, 这样设计程序将会更加得心应手。 程序设计就是这样一门神奇的课程,只有勤于思考,刻苦钻研,勇于创新才能,才

8、能设计出满意的程序。相关附录#include <iostream>#include<string>#include<stdlib.h>#include<fstream>using namespace std;#define NULL 0class student/定义类public:longnum;char name20;int age;char sex20;char address30;float computer_score;float math_score;float English_score;精品资料_student *next;int

9、 n;/定义主函数int main()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);int save(student *head);void print(student*);

10、student *head=NULL,*stu;long del_numb,correct_numb,search_numb; int choose,a;string search_name,correct_name;start:cout<<"*学生信息管理系统* " <<endl;/ goto指向的位置精品资料_cout<<"* * "<<endl;cout<<"*1. 输入学生信息 *"<<endl;cout<<"*2. 插入学生信息 *

11、"<<endl;cout<<"*3. 修改学生信息 *"<<endl;cout<<"*4. 删除学生信息 *"<<endl;cout<<"*5. 显示学生信息 *"<<endl;cout<<"*6. 查询学生信息 *"<<endl;cout<<"*7.退出 *"<<endl;cout<<" 请输入您的选择 (1-7):"&l

12、t;<endl;cin>>choose;switch(choose)/选择结构,选择要进行的操作case 1:system("cls"); / 系统清屏cout<<" 输入学生信息 :"<<endl;精品资料_head=creat();/ 调用函数,建立链表system("cls");goto start;/ 返回目录break;case 2:system("cls");cout<<endl<<" 输入要插入的学生信息 :"stu

13、=new student;/新建结点cout<<" 学生的学号: "cin>>stu->num;cout<<" 学生的姓名: " ;cin>>stu->name;cout<<" 学生的年龄: "cin>>stu->age;cout<<" 学生的性别: " ;cin>>stu->sex;cout<<" 学生的住址: " ;cin>>stu->addr

14、ess;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);/ 将数据储存在

15、文件中cout<<endl<<" 输入要继续插入的学生信息:"stu=new student;cout<<" 学生的学号: "cin>>stu->num;/输入结点相关信息cout<<" 学生的姓名: " ;cin>>stu->name;cout<<" 学生的年龄: "cin>>stu->age;cout<<" 学生的性别: " ;cin>>stu->s

16、ex;cout<<" 学生的住址: " ;cin>>stu->address;cout<<" 学生的电脑成绩: " ;cin>>stu->computer_score;cout<<" 学生的数学成绩: " ;cin>>stu->math_score;cout<<" 学生的英语成绩: " ;cin>>stu->English_score;精品资料_system("cls");go

17、to start;break;case 3:system("cls");cout<<endl<<" 输入要修改信息学生的学号/姓"<<endl;cout<<" 按学号查询输入1,姓名查询输入 "<<endl;cin>>a;if(a=1)cout<<endl<<" 要修改信息学生的学号 :"cin>>correct_numb ;head=correct_num(head,correct_numb);/按学号修改

18、学生信息save(head);if(a=2)cout<<endl<<" 要修改信息学生的姓名 :"cin>>correct_name;head=correct_nam(head,correct_name);/ 按姓名修改学生信息 save(head);system("cls");goto start;精品资料_break;case 4:system("cls");cout<<endl<<" 输入要删除学生的学号:"cin>>del_numb;w

19、hile(del_numb!=0)head=del(head,del_numb);save(head);cout<<" 请输入要继续删除学生的学号:"cin>>del_numb;system("cls");goto start;break;case 5:system("cls");cout<<" 学生信息如下: "<<endl;system("cls");print(head);system("pause");/ 运行停在当前页

20、面system("cls");goto start;break;case 6:system("cls");精品资料_cout<<endl<<" 输入要查询信息学生的学号/ 姓名:"<<endl;cout<<" 按学号查询输入1 ,姓名查询输入2 :"<<endl;cin>>a;system("cls");if(a=1)cout<<endl<<" 要查询信息学生的学号 :"cin&g

21、t;>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");goto start;break;case 7:system("cls");cout<<"

22、; 按任意键退出程序! "精品资料_exit(0);break;/ 调用系统函数 exit, 运行结束default:cout<<endl<<" 请重新选择 1-7 中的数字! "/输入非选项数字时,返回主菜单system("pause");system("cls");goto start;break;return 0;/创建链表的函数student *creat(void)ofstream outfile("f1.dat",ios:out);/打开文件if(!outfile)ce

23、rr<<" 打开失败 "<<endl;exit(0);student *head;student *p1,*p2;n=0;p1=p2=new student;/ 新建对象cout<<" 学生的学号: "cin>>p1->num;精品资料_outfile<<p1->num<<" " /将数据存入文件cout<<" 学生的姓名: " ;cin>>p1->name;outfile<<p1->

24、name<<" "cout<<" 学生的年龄: "cin>>p1->age;outfile<<p1->age<<" "cout<<" 学生的性别: " ;cin>>p1->sex;outfile<<p1->sex<<" "cout<<" 学生的住址: " ;cin>>p1->address;outfile<&l

25、t;p1->address<<" "cout<<" 学生的电脑成绩: " ;cin>>p1->computer_score;outfile<<p1->computer_score<<" "cout<<" 学生的数学成绩: " ;cin>>p1->math_score;outfile<<p1->math_score<<" "cout<<"

26、学生的英语成绩: " ;cin>>p1->English_score;outfile<<p1->English_score<<" "精品资料_head=NULL;while(p1->num!=0)n=n+1;if(n=1) head=p1;else p2->next=p1;/p1指向下一个结点p2=p1;p1=new student;cout<<" 学生的学号: "cin>>p1->num;outfile<<p1->num<<

27、" "cout<<" 学生的姓名: " ;cin>>p1->name;outfile<<p1->name<<" "cout<<" 学生的年龄: "cin>>p1->age;outfile<<p1->age<<" "cout<<" 学生的性别: " ;cin>>p1->sex;outfile<<p1->sex&l

28、t;<" "cout<<" 学生的住址: " ;cin>>p1->address;outfile<<p1->address<<" "精品资料_cout<<" 学生的电脑成绩: " ;cin>>p1->computer_score;outfile<<p1->computer_score<<" "cout<<" 学生的数学成绩: " ;cin&

29、gt;>p1->math_score;outfile<<p1->math_score<<" "cout<<" 学生的英语成绩: " ;cin>>p1->English_score;outfile<<p1->English_score<<" "p2->next=NULL;outfile.close();/ 关闭文件return(head);/保存文件的函数int save(student *head)ofstream outfil

30、e("f1.dat",ios:out);if(!outfile)cerr<<" 打开文件出错! "<<endl;exit(0);student *p1=head,*p2;if(head=NULL)精品资料_cout<<" 列表为空! "<<endl;return 0;dooutfile<<p1->num<<""<<p1->name<<""<<p1->age<<

31、""<<p1->sex<<""<<p1->address<<""<<p1->computer_score<<""<<p1->math_score<<" "<<p1->English_score;/将链表数据存入文件p2=p1;p1=p1->next;while(p2->next!=NULL);outfile.close();return 0;/删除

32、数据的函数student *del(student *head,long num)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;/如果找到else p2->next=p1->next;cout&

33、lt;<" 删除的学号: "<<num<<endl;精品资料_n=n-1;else cout<<" 不能找到此学号的学生:"<<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;elsewhile(p0->num>p1->num)&&

34、;(p1->next!=NULL)p2=p1;p1=p1->next;if(p0->num<=p1->num)if(head=p1)head=p0;/p1学号最小,则作为头指针else p2->next=p0;/ 否则插入中间p0->next=p1;elsep1->next=p0;p0->next=NULL;/如果最大,则放在最后精品资料_n=n+1;/ 记录结点数return(head);/按学号修改学生信息的函数student *correct_num(student *head,long num)student *p;if(head=

35、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<<" 学生的年龄: "

36、;cin>>p->age;cout<<" 学生的性别: " ;cin>>p->sex;cout<<" 学生的住址: " ;精品资料_cin>>p->address;cout<<" 学生的电脑成绩: " ;cin>>p->computer_score;cout<<" 学生的数学成绩: " ;cin>>p->math_score;cout<<" 学生的英语成绩:

37、 " ;cin>>p->English_score;else cout<<" 不能找到此学号的学生: "<<num; return(head);/按姓名修改学生信息的函数student *correct_nam(student*head,string name)student *p;if(head=NULL)cout<<" 列表为空 !"<<endl;return(head);p=head;while(name!=p->name&&p->next!=N

38、ULL)p=p->next;if(p->name=name)cout<<endl<<" 请重新输入此学生的信息"cout<<" 学生的学号: "精品资料_cin>>p->num;cout<<" 学生的姓名: " ;cin>>p->name;cout<<" 学生的年龄: "cin>>p->age;cout<<" 学生的性别: " ;cin>>p-&g

39、t;sex;cout<<" 学生的住址: " ;cin>>p->address;cout<<" 学生的电脑成绩: " ;cin>>p->computer_score;cout<<" 学生的数学成绩: " ;cin>>p->math_score;cout<<" 学生的英语成绩: " ;cin>>p->English_score;else cout<<" 不能找到此学号的学生:

40、"<<name; return(head);/按学号查询学生信息的函数student *search_num(student *head,long num)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->

温馨提示

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

评论

0/150

提交评论