C++ C语言 程序设计 简单的职工信息管理系统Word格式.docx
《C++ C语言 程序设计 简单的职工信息管理系统Word格式.docx》由会员分享,可在线阅读,更多相关《C++ C语言 程序设计 简单的职工信息管理系统Word格式.docx(15页珍藏版)》请在冰豆网上搜索。
string>
fstream>
cstdlib>
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<
<
"
**********************"
endl;
请输入学生信息:
do
p=newstudentnode;
cin.ignore();
姓名:
;
gets(p->
name);
i=0;
p->
totalmark=0;
科目:
mark[i].subject);
成绩(0--100):
cin>
>
mark[i].score;
while(p->
mark[i].score>
100||p->
mark[i].score<
0);
totalmark=p->
totalmark+p->
getchar();
while(++i!
=SUBJECT);
if(head->
next==NULL)
next=p;
else
next=head->
next;
继续添加?
yorn:
check=getchar();
while(check!
='
n'
&
&
check!
N'
return0;
countmark()
studentnode*p=head->
if(p==NULL)
没有学生,请重新输入"
pause"
***************"
学生成绩汇总:
while(p)
name<
总成绩:
totalmark<
p=p->
save()
charaddress[35];
请输入保存的地址"
gets(address);
ofstreamfout;
fout.open(address,ios:
app|ios:
out);
fout<
*"
while(i!
=SUBJECT)
mark[i].subject<
i++;
fout.flush();
fout.close();
已经保存,请查阅"
~student()
studentnode*p,*s;
p=head->
s=p->
deletep;
p=s;
deletehead;
sortbymark()
studentnode*move1=head->
studentnode*move2,*max,*pre1,*pre2,*maxpre,*s=move1;
没有记录,请添加"
for(pre1=head,max=move1,maxpre=pre1;
move1->
next!
=NULL;
pre1=move1,maxpre=pre1,move1=move1->
next,max=move1)
for(pre2=move1,move2=move1->
move2!
pre2=move2,move2=move2->
next)
if(move2->
totalmark>
max->
totalmark)
maxpre=pre2;
max=move2;
if(move1->
next==max)
pre1->
next=max;
next=max->
next=move1;
move1=max;
}
else
s=move1->
next=s;
maxpre->
已经按照从大到小排序"
show()
next==NULL){cout<
没有学生记录,请添加"
return0;
name;
i=1;
=SUBJECT+1)
mark[i-1].subject;
成绩:
mark[i-1].score;
display()
ifstreamfin;
charbuf[100];
charstr[25];
请输入路径及文件名:
gets(str);
fin.open(str);
if(!
fin)
没有此文件"
while(fin)
fin.getline(buf,sizeof(buf));
buf<
readfiletolist()
fin.ignore(100,'
*'
fin.getline(p->
name,100,'
mark[i].subject,100,'
fin>
totalmark+=p->
信息已经保存在链表中"
searchbyname()
没有学生,请添加或者从文件中读取"
charfindname[10];
请输入姓名:
gets(findname);
strcmp(p->
name,findname))
经查找,找到该生信息如下:
endl<
return1;
没有此学生,请添加或者从文件中读取"
intshowmenu()
intchoice;
char*menu[9]={
1:
输入学生成绩保存到链表\n"
2:
计算每位学生总成绩\n"
3:
按照总成绩大小对记录进行排序\n"
4:
输出所有学生成绩到一个文件中\n"
5:
显示新输入的学生信息\n"
6:
从文件中读取信息\n"
7:
将文件信息保存在链表中\n"
8:
根据姓名查找学生记录\n"
9:
结束程序\n"
"
*****************************************************"
*"
学生成绩管理系统"
for(choice=0;
choice<
9;
choice++)
menu[choice];
pleasechoosetocontinue"
choice;
while(choice>
9||choice<
1);
returnchoice;
intmain()
intmenuitem,flag=1;
studentstu;
while(flag)
menuitem=showmenu();
switch(menuitem)
case1:
{stu.addstudent();
break;
case2:
{stu.countmark();
case3:
{stu.sortbymark();
case4:
{stu.save();
case5:
{stu.show();
case6:
{stu.display();
case7:
{stu.readfiletolist();
case8:
{stu.searchbyname();
case9:
{flag=0;