C++ C语言 程序设计 简单的职工信息管理系统.docx
- 文档编号:7749221
- 上传时间:2023-01-26
- 格式:DOCX
- 页数:15
- 大小:125.18KB
C++ C语言 程序设计 简单的职工信息管理系统.docx
《C++ C语言 程序设计 简单的职工信息管理系统.docx》由会员分享,可在线阅读,更多相关《C++ C语言 程序设计 简单的职工信息管理系统.docx(15页珍藏版)》请在冰豆网上搜索。
C++C语言程序设计简单的职工信息管理系统
C++程序设计语言结业报告
课程名称
C++程序设计语言
班级
B1101
实验日期
12月15日
姓名
学号
实验成绩
名称
C++程序设计语言
实验目的及要求
掌握VisualC++集成环境下调试标准C++程序的方法
实验环境
VisualC++集成环境、WindowsXP操作系统
实验内容
1.用C++语言开发“简单的学生成绩管理系统”。
算法描述及实验步骤
学生成绩管理系统分为9个模块,分别是:
输入学生成绩保存到链表,计算每位学生总成绩,按照总成绩大小对记录进行排序,输出所有学生成绩到一个文件中,显示新输入的学生信息,从文件中读取信息,将文件信息保存在链表中,根据姓名查找学生记录,结束程序。
调试过程及实验结果
总结
这个实验的结果是我之前说预想的,但是总的来看的话还是有缺点的,比如系或者院校没有说明,总的范围还是蛮大的,没有精确性。
改进的意见就是可以多加一点选项使系统更详细。
附录
#include
#include
#include
#include
usingnamespacestd;
enum{SUBJECT=5};
typedefstruct
{
charsubject[10];
intscore;
}markinfo;
typedefstructstudentnode
{
markinfomark[SUBJECT];
inttotalmark;
charname[10];
studentnode*next;
}studentnode;
classstudent
{
studentnode*head;
public:
student();
intaddstudent();
~student();
intcountmark();
intsortbymark();
intsave();
intshow();
intdisplay();
intreadfiletolist();
intsearchbyname();
};
student:
:
student()
{
head=newstudentnode;
head->next=NULL;
}
intstudent:
:
addstudent()
{
studentnode*p;
inti;
charcheck;
system("cls");
cout<<"**********************"< cout<<"请输入学生信息: "< do { p=newstudentnode; cin.ignore(); cout<<"姓名: "; gets(p->name); i=0; p->totalmark=0; do { cout<<"科目: "; gets(p->mark[i].subject); cout<<"成绩(0--100): "; do { cin>>p->mark[i].score; } while(p->mark[i].score>100||p->mark[i].score<0); p->totalmark=p->totalmark+p->mark[i].score; getchar(); } while(++i! =SUBJECT); if(head->next==NULL) { head->next=p;p->next=NULL; } else { p->next=head->next; head->next=p; } cout<<"继续添加? yorn: "; check=getchar(); } while(check! ='n'&&check! ='N'); return0; } intstudent: : countmark() { studentnode*p=head->next; if(p==NULL) { cout<<"没有学生,请重新输入"< } else { cout<<"***************"< cout<<"学生成绩汇总: "< while(p) { cout<<"姓名: "< "< p=p->next; } } system("pause"); return0; } intstudent: : save() { charaddress[35]; inti; studentnode*p=head->next; cout<<"请输入保存的地址"< cin.ignore(); gets(address); ofstreamfout; fout.open(address,ios: : app|ios: : out); while(p) { fout<<"*"; fout< i=0; while(i! =SUBJECT) { fout< fout< i++; } p=p->next; } fout.flush(); fout.close(); cout<<"已经保存,请查阅"; system("pause"); return0; } student: : ~student() { studentnode*p,*s; p=head->next; while(p) { s=p->next; deletep; p=s; } deletehead; } intstudent: : sortbymark() { studentnode*move1=head->next; studentnode*move2,*max,*pre1,*pre2,*maxpre,*s=move1; if(head->next==NULL) { cout<<"没有记录,请添加"< } for(pre1=head,max=move1,maxpre=pre1;move1->next! =NULL;pre1=move1,maxpre=pre1,move1=move1->next,max=move1) { for(pre2=move1,move2=move1->next;move2! =NULL;pre2=move2,move2=move2->next) if(move2->totalmark>max->totalmark) { maxpre=pre2; max=move2; } if(move1->next==max) { pre1->next=max; move1->next=max->next; max->next=move1; move1=max; } else { s=move1->next; move1->next=max->next; max->next=s; maxpre->next=move1; pre1->next=max; move1=max; } } cout<<"已经按照从大到小排序"< system("pause"); return0; } intstudent: : show() { studentnode*p=head->next; inti; if(head->next==NULL){cout<<"没有学生记录,请添加"< else { while(p) { cout<<"姓名: "< i=1; while(i! =SUBJECT+1) { cout<<"科目: "< cout<<"成绩: "< i++; } cout< p=p->next; } } system("pause"); return0; } intstudent: : display() { ifstreamfin; charbuf[100]; charstr[25]; cout<<"请输入路径及文件名: "< cin.ignore(); gets(str); fin.open(str); if(! fin) { cout<<"没有此文件"< system("pause"); return0; } while(fin) { fin.getline(buf,sizeof(buf)); cout< } system("pause"); return0; } intstudent: : readfiletolist() { ifstreamfin; inti; charstr[25]; cout<<"请输入路径及文件名: "< cin.ignore(); gets(str); fin.open(str); if(! fin) { cout<<"没有此文件"< system("pause"); return0; } studentnode*p; fin.ignore(100,'*'); while(fin) { p=newstudentnode; p->totalmark=0; fin.getline(p->name,100,'*'); i=0; while(i! =SUBJECT) { fin.getline(p->mark[i].subject,100,'*'); fin>>p->mark[i].score; p->totalmark+=p->mark[i].score; i++; } if(head->next==NULL) { head->next=p; p->next=NULL; } else { p=head->next; head->next=p; } } cout<<"信息已经保存在链表中"< system("pause"); return0; } intstudent: : searchbyname() { if(head->next==NULL) { cout<<"没有学生,请添加或者从文件中读取"< system("pause"); return0; } studentnode*p=head->next; charfindname[10]; inti; cout<<"请输入姓名: "; cin.ignore(); gets(findname); while(p) { if(! strcmp(p->name,findname)) { cout<<"经查找,找到该生信息如下: "< cout<<"姓名: "< i=1; while(i! =SUBJECT+1) { cout<<"科目: "< cout<<"成绩: "< i++; } cout< system("pause"); return1; } p=p->next; } cout<<"没有此学生,请添加或者从文件中读取"< system("pause"); return0; } intshowmenu() { intchoice; char*menu[9]={ "1: 输入学生成绩保存到链表\n", "2: 计算每位学生总成绩\n", "3: 按照总成绩大小对记录进行排序\n", "4: 输出所有学生成绩到一个文件中\n", "5: 显示新输入的学生信息\n", "6: 从文件中读取信息\n", "7: 将文件信息保存在链表中\n", "8: 根据姓名查找学生记录\n", "9: 结束程序\n" }; cout<<""<<"*****************************************************"< cout<<"*"<<""<<"学生成绩管理系统"<<"*"< cout<<""<<"*****************************************************"< for(choice=0;choice<9;choice++) cout<<""<
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- C+ C语言 程序设计 简单的职工信息管理系统 语言 简单 职工 信息管理 系统