李金霖c++项目设计Word文档格式.docx

上传人:b****6 文档编号:18757747 上传时间:2023-01-01 格式:DOCX 页数:23 大小:21.76KB
下载 相关 举报
李金霖c++项目设计Word文档格式.docx_第1页
第1页 / 共23页
李金霖c++项目设计Word文档格式.docx_第2页
第2页 / 共23页
李金霖c++项目设计Word文档格式.docx_第3页
第3页 / 共23页
李金霖c++项目设计Word文档格式.docx_第4页
第4页 / 共23页
李金霖c++项目设计Word文档格式.docx_第5页
第5页 / 共23页
点击查看更多>>
下载资源
资源描述

李金霖c++项目设计Word文档格式.docx

《李金霖c++项目设计Word文档格式.docx》由会员分享,可在线阅读,更多相关《李金霖c++项目设计Word文档格式.docx(23页珍藏版)》请在冰豆网上搜索。

李金霖c++项目设计Word文档格式.docx

};

student:

:

student()//用构造函数来初始化。

head=newstudentnode;

head->

next=NULL;

}

//1.输入学生姓名、成绩等数据,并保存在链表中。

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;

//2.计算每位学生总成绩。

countmark()

studentnode*p=head->

if(p==NULL)

没有学生,请重新输入"

pause"

***************"

学生成绩汇总:

while(p)

name<

总成绩:

totalmark<

p=p->

//4.输出所有学生成绩到一个文件中。

save()

charaddress[35];

请输入保存的地址"

gets(address);

ofstreamfout;

fout.open(address,ios:

app|ios:

out);

fout<

*"

while(i!

=SUBJECT)

mark[i].subject<

i++;

//fout<

fout.flush();

fout.close();

已经保存,请查阅"

~student()//析构函数

studentnode*p,*s;

p=head->

s=p->

deletep;

p=s;

deletehead;

//3.按照总成绩大小对记录进行排序

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)//交换max和move1。

pre1->

next=max;

next=max->

next=move1;

move1=max;

s=move1->

next=s;

maxpre->

已经按照从大到小排序"

//5输出输入的信息

show()

next==NULL){cout<

没有学生记录,请添加"

return0;

name;

i=1;

=SUBJECT+1)

mark[i-1].subject;

成绩:

mark[i-1].score;

//6:

从文件按读取记录

display()

ifstreamfin;

charbuf[100];

charstr[25];

请输入路径及文件名:

gets(str);

fin.open(str);

if(!

fin)

没有此文件"

while(fin)

fin.getline(buf,sizeof(buf));

buf<

//8从文件中读取数据,并将数据保存在链表中

readfiletolist()

fin.ignore(100,'

*'

fin.getline(p->

name,100,'

mark[i].subject,100,'

fin>

totalmark+=p->

信息已经保存在链表中"

//9根据姓名进行查找

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;

}

 

//管理系统代码2

#include<

stdio.h>

ctype.h>

#defineN10

char*course[N]=

高等数学(上)"

高等数学(下)"

大学英语(上)"

大学英语(下)"

体育(上)"

体育(下)"

C++程序设计"

通信原理"

课程为数据库"

通信应用系统开发"

typedefstructstudentNode

stringstudentNumber;

stringname;

intscore[N];

studentNode*next;

classStudent

studentNode*head;

Student();

~Student();

voidcreateStudentInfo();

voidaddStudentInfo();

voiddelStudentInfo();

voidmodificationStudentInfo();

voidwrite2File();

voidshow();

voidreferCourseScore();

voidreferStudentInfo();

voidreferAverageScore();

voidreferByName();

voidreferByStudentNumber();

voidreferTheHightScore();

voidreferTheFallStudent();

Student:

Student()//用构造函数来初始化。

head=newstudentNode;

~Student()//析构函数

studentNode*p,*s;

voidStudent:

referTheHightScore()

studentNode*p=head->

stringrecordstudentNumber[N];

inttheHighScore[N];

return;

i=0;

while(i<

N)

recordstudentNumber[i]=p->

studentNumber;

theHighScore[i]=p->

score[i];

p=p->

next;

i=1;

intj;

for(j=0;

j<

N;

j++)

if(theHighScore[j]<

p->

score[j])

theHighScore[j]=p->

score[j];

recordstudentNumber[j]=p->

p=p->

p=head->

for(intj=0;

if(recordstudentNumber[j]==p->

studentNumber)

学号:

studentNumber;

\n科目:

course[i];

成绩:

<

referTheFallStudent()

if(p->

score[i]<

60)

createStudentInfo()

if(head->

next==NULL)

增加学生信息"

addStudentInfo();

addStudentInfo()

studentNode*p;

p=newstudentNode;

cin>

p->

name;

co

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 自然科学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1