完整word版c++项目设计.docx

上传人:b****2 文档编号:13929947 上传时间:2023-06-19 格式:DOCX 页数:29 大小:21.71KB
下载 相关 举报
完整word版c++项目设计.docx_第1页
第1页 / 共29页
完整word版c++项目设计.docx_第2页
第2页 / 共29页
完整word版c++项目设计.docx_第3页
第3页 / 共29页
完整word版c++项目设计.docx_第4页
第4页 / 共29页
完整word版c++项目设计.docx_第5页
第5页 / 共29页
完整word版c++项目设计.docx_第6页
第6页 / 共29页
完整word版c++项目设计.docx_第7页
第7页 / 共29页
完整word版c++项目设计.docx_第8页
第8页 / 共29页
完整word版c++项目设计.docx_第9页
第9页 / 共29页
完整word版c++项目设计.docx_第10页
第10页 / 共29页
完整word版c++项目设计.docx_第11页
第11页 / 共29页
完整word版c++项目设计.docx_第12页
第12页 / 共29页
完整word版c++项目设计.docx_第13页
第13页 / 共29页
完整word版c++项目设计.docx_第14页
第14页 / 共29页
完整word版c++项目设计.docx_第15页
第15页 / 共29页
完整word版c++项目设计.docx_第16页
第16页 / 共29页
完整word版c++项目设计.docx_第17页
第17页 / 共29页
完整word版c++项目设计.docx_第18页
第18页 / 共29页
完整word版c++项目设计.docx_第19页
第19页 / 共29页
完整word版c++项目设计.docx_第20页
第20页 / 共29页
亲,该文档总共29页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

完整word版c++项目设计.docx

《完整word版c++项目设计.docx》由会员分享,可在线阅读,更多相关《完整word版c++项目设计.docx(29页珍藏版)》请在冰点文库上搜索。

完整word版c++项目设计.docx

完整word版c++项目设计

//学生管理系统代码

#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;

}

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

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;

}

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

intstudent:

:

countmark()

{

studentnode*p=head->next;

if(p==NULL)

{

cout<<"没有学生,请重新输入"<

}

else

{

cout<<"***************"<

cout<<"学生成绩汇总:

"<

while(p)

{

cout<<"姓名:

"<name<<"总成绩:

"<totalmark<

p=p->next;

}

}

system("pause");

return0;

}

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

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<name<<"*";

i=0;

while(i!

=SUBJECT)

{

fout<mark[i].subject<<"*";

fout<mark[i].score;

i++;

}

//fout<<"*";

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;

}

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

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

{

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;

}

//5输出输入的信息

intstudent:

:

show()

{

studentnode*p=head->next;

inti;

if(head->next==NULL){cout<<"没有学生记录,请添加"<

else

{

while(p)

{

cout<<"姓名:

"<name;

i=1;

while(i!

=SUBJECT+1)

{

cout<<"科目:

"<mark[i-1].subject;

cout<<"成绩:

"<mark[i-1].score;

i++;

}

cout<

p=p->next;

}

}

system("pause");

return0;

}

//6:

从文件按读取记录

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;

}

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

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;

}

//9根据姓名进行查找

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<<"姓名:

"<name;

i=1;

while(i!

=SUBJECT+1)

{

cout<<"科目:

"<mark[i-1].subject;

cout<<"成绩:

"<mark[i-1].score;

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<<""<

cout<<""<<"*****************************************************"<

cout<<"pleasechoosetocontinue"<

do

{

cin>>choice;

}

while(choice>9||choice<1);

returnchoice;

}

intmain()

{

intmenuitem,flag=1;

studentstu;

while(flag)

{

system("cls");

menuitem=showmenu();

switch(menuitem)

{

case1:

{stu.addstudent();break;}

case2:

{stu.countmark();break;}

case3:

{stu.sortbymark();break;}

case4:

{stu.save();break;}

case5:

{stu.show();break;}

case6:

{stu.display();break;}

case7:

{stu.readfiletolist();break;}

case8:

{stu.searchbyname();break;}

case9:

{flag=0;break;}

}

}

return0;

}

 

//管理系统代码2

#include

#include

#include

#include

#include

#defineN10

usingnamespacestd;

char*course[N]=

{

"高等数学(上)",

"高等数学(下)",

"大学英语(上)",

"大学英语(下)",

"体育(上)",

"体育(下)",

"C++程序设计",

"通信原理",

"课程为数据库",

"通信应用系统开发"

};

typedefstructstudentNode

{

stringstudentNumber;

stringname;

intscore[N];

studentNode*next;

};

classStudent

{

studentNode*head;

public:

Student();

~Student();

voidcreateStudentInfo();

voidaddStudentInfo();

voiddelStudentInfo();

voidmodificationStudentInfo();

voidwrite2File();

voidshow();

voidreferCourseScore();

voidreferStudentInfo();

voidreferAverageScore();

voidreferByName();

voidreferByStudentNumber();

voidreferTheHightScore();

voidreferTheFallStudent();

};

Student:

:

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

{

head=newstudentNode;

head->next=NULL;

}

Student:

:

~Student()//析构函数

{

studentNode*p,*s;

p=head->next;

while(p)

{

s=p->next;

deletep;

p=s;

}

deletehead;

}

voidStudent:

:

referTheHightScore()

{

studentNode*p=head->next;

inti;

stringrecordstudentNumber[N];

inttheHighScore[N];

if(head->next==NULL)

{

cout<<"没有学生记录,请添加"<

system("pause");

return;

}

else

{

i=0;

while(i

{

recordstudentNumber[i]=p->studentNumber;

theHighScore[i]=p->score[i];

i++;

}

p=p->next;

i=1;

while(p)

{

intj;

for(j=0;j

{

if(theHighScore[j]score[j])

{

theHighScore[j]=p->score[j];

recordstudentNumber[j]=p->studentNumber;

}

}

p=p->next;

}

}

p=head->next;

if(head->next==NULL)

{

cout<<"没有学生记录,请添加"<

system("pause");

return;

}

else

{

for(intj=0;j

{

while(p)

{

i=0;

if(recordstudentNumber[j]==p->studentNumber)

{

cout<<"姓名:

"<name;

cout<<"学号:

"<studentNumber;

while(i

{

cout<<"\n科目:

"<

cout<<"成绩:

"<score[i];

i++;

}

}

cout<

p=p->next;

}

p=head->next;

}

}

system("pause");

}

voidStudent:

:

referTheFallStudent()

{

studentNode*p=head->next;

inti;

if(head->next==NULL)

{

cout<<"没有学生记录,请添加"<

system("pause");

return;

}

else

{

while(p)

{

while(i

{

if(p->score[i]<60)

{

cout<<"姓名:

"<name;

cout<<"学号:

"<studentNumber;

cout<<"\n科目:

"<

cout<<"成绩:

"<score[i];

}

i++;

}

i=0;

cout<

p=p->next;

}

}

system("pause");

}

voidStudent:

:

show()

{

studentNode*p=head->next;

inti;

if(head->next==NULL)

{

cout<<"没有学生记录,请添加"<

system("pause");

return;

}

else

{

while(p)

{

cout<<"姓名:

"<name;

cout<<"学号:

"<studentNumber;

i=0;

while(i

{

cout<<"\n科目:

"<

cout<<"成绩:

"<score[i];

i++;

}

cout<

p=p->next;

}

}

system("pause");

}

voidStudent:

:

createStudentInfo()

{

if(head->next==NULL)

{

cout<<"增加学生信息"<

system("pause");

}

addStudentInfo();

}

voidStudent:

:

addStudentInfo()

{

studentNode*p;

inti;

charcheck;

system("cls");

cout<<"**********************"<

cout<<"请输入学生信息:

"<

do

{

i=0;

p=newstudentNode;

cin.ignore();

cout<<"姓名:

";

cin>>p->name;

cout<<"学号:

";

cin>>p->studentNumber;

do

{

cout<<"科目:

"

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

当前位置:首页 > PPT模板 > 艺术创意

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2