
C++问题的高分悬赏 100
WriteaCLIprogramthatreadsscoresandnameofstudents,andprintsoutasummarysheet.Theusercan...
Write a CLI program that reads scores and name of students, and prints out a summary sheet.
The user can input as many students as possible. There's no limit for the number of students. One students can have as many courses as possible. There's no limit for the number of courses. One course consists the name of the course and the marks the student got.
You may have your own idea to get data input and output. Notice that marks of the same course, which is identified by the name of the course, should be printed in one column.
简单地说, 需要实现一个简易的学生分数管理系统. 系统的输入输出你可以自
己设计,也没必要太复杂, 但是系统的架构应该是面向对象的.
在此说明一下,我是初学c++的,以前只学过c,学了没几堂课,老师要我们写这个,我实在一点思路都没有,下面说的vector什么的我听都没听过……有谁可以帮我搞定或者教教我,付费当然也可以了……
我这儿有一个做好的可执行程序,要的人可以加Q415396212,哪位仁兄帮帮忙,感激不尽了…… 展开
The user can input as many students as possible. There's no limit for the number of students. One students can have as many courses as possible. There's no limit for the number of courses. One course consists the name of the course and the marks the student got.
You may have your own idea to get data input and output. Notice that marks of the same course, which is identified by the name of the course, should be printed in one column.
简单地说, 需要实现一个简易的学生分数管理系统. 系统的输入输出你可以自
己设计,也没必要太复杂, 但是系统的架构应该是面向对象的.
在此说明一下,我是初学c++的,以前只学过c,学了没几堂课,老师要我们写这个,我实在一点思路都没有,下面说的vector什么的我听都没听过……有谁可以帮我搞定或者教教我,付费当然也可以了……
我这儿有一个做好的可执行程序,要的人可以加Q415396212,哪位仁兄帮帮忙,感激不尽了…… 展开
4个回答
展开全部
#include<iostream.h>
#include<string.h>
#include<fstream.h>
#include<stdlib.h>
#include<iomanip.h>
class stu //通过定义一个类来定义数据录入的函数
{
char name[20];
int number;
double math,cjia,english,average,sum;
public:
stu()
{};
stu ( char n[20], int num,double ma,double cj,double eng )
{
strcpy(name,n); //得到姓名
number=num; //得到学号
math=ma; //得到数学成绩
cjia=cj; //得到c++成绩
english=eng; //得到英语成绩
}
double getsum() //得到总分的函数
{
sum=cjia+english+math;
return sum;
}
double getaver() //得到平均分的函数
{
average=getsum()/3;
return average;
}
friend void main(); //将主函数定义为友元函数,方便访问类中的成员
};
void main()
{
cout<<"*****************欢迎来到学生成绩查询系统*****************"<<endl;
cout<<"请选择您需要的操作!"<<endl; //菜单的输出
cout<<"操作:"<<endl;
cout<<"(0)数据录入"<<endl;
cout<<"(1)增加学生"<<endl;
cout<<"(2)删除学生"<<endl;
cout<<"(3)修改数据"<<endl;
cout<<"查询:"<<endl;
cout<<"(4)按总成绩查询"<<endl;
cout<<"(5)按姓名查询"<<endl;
cout<<"(6)按学号查询"<<endl;
cout<<"(7)输出所有学生的数据"<<endl;
cout<<"成绩统计:"<<endl;
cout<<"(8)各科平均成绩和各科成绩优秀,良好,中等,及格,不及格,的人数及其所占比例:"<<endl;
cout<<"读取与保存:"<<endl;
cout<<"(9)学生信息的读取与保存:"<<endl;
cout<<"成绩名次:"<<endl;
cout<<"(x)按总分查询排名"<<endl;
cout<<"(y)按英语查询排名"<<endl;
cout<<"(z)按数学查询排名"<<endl;
cout<<"(u)按C++查询排名"<<endl;
cout<<"选择相关操作请输入相对的括号里的阿拉伯数字及字母!"<<endl;
char p; //全局变量,用于选择菜单时的输入
char w; //全局变量,用于在大项中选择是否继续操作
stu *s[100]; //类定义的指针将所录入的数据按类中的形式分别存储
ofstream *file[100];
int i=0; //全局变量,用于做每个录入数据的下标
int j=0;
double chris1=0; //用于判断do—while语句
do //判断输入是否正确
{
cin>>p;
if((p>='0'&&p<='z'))
chris1=1;
else
cout<<"指令错误!请重新输入:"<<endl;
}while(chris1==0);
do{
switch(p)
{
case '0': //数据的录入
{
char c; //用于在小项中选择是否继续操作
char name[20];
int number;
double math,cjia,english;
do{
cout<<"请输入姓名:"<<endl;
cin>>name;
cout<<"请输入学号:"<<endl;
cin>>number;
cout<<"请输入数学成绩:"<<endl;
cin>>math;
cout<<"请输入C++成绩:"<<endl;
cin>>cjia;
cout<<"请输入英语成绩:"<<endl;
cin>>english;
fstream outfile,infile; //作一个文本文档在文件夹中用于显示所录入的数据
outfile.open("f1.txt",ios::out);
if(!file)
{
cout<<"f1.txt can not open.\n";
abort();
}
outfile<<"姓名:"<<name<<"学号:"<<number<<"数学成绩:"<<math<<"C++成绩:"<<cjia<<"外语成绩:"<<english<<endl;
outfile.close();
infile.open("f1.txt",ios::in);
if(!file) //判断文件是否打开
{
cout<<"f1.txt can not open.\n";
abort();
}
char ch;
while(infile.get(ch))
cout<<ch;
cout<<endl;
infile.close();
j++;
s[i]=new stu(name, number,math, cjia, english);
i++;
cout<<"数据录入成功,想继续录入吗(y/n)"<<endl;
cin>>c;
chris1=0;
do{
if(c!='y'&&c!='n')
{
cout<<"指令错误!请重新输入!"<<endl;
cin>>c;
}
else
chris1=1;
}while(chris1==0);
}while(c=='y'); //重复输入
break;
}
case '1': //增加学生数据
{
char name[20];
int number;
double math,cjia,english;
char c;
do
{
cout<<"请输入您要增加的学生的姓名:"<<endl;
cin>>name;
cout<<"请输入你要增加的学生的学号:"<<endl;
cin>>number;
cout<<"请输入数学成绩:"<<endl;
cin>>math;
cout<<"请输入C++成绩:"<<endl;
cin>>cjia;
cout<<"请输入英语成绩:"<<endl;
cin>>english;
fstream outfile,infile;
outfile.open("f2.txt",ios::out);
if(!file)
{
cout<<"f2.txt can not open.\n";
abort();
}
outfile<<"姓名:"<<name<<"学号:"<<number<<"数学成绩:"<<math<<"C++成绩:"<<cjia<<"外语成绩:"<<english<<endl;
outfile.close();
infile.open("f2.txt",ios::in);
if(!file)
{
cout<<"f2.txt can not open.\n";
abort();
}
char h;
while(infile.get(h))
cout<<h;
cout<<endl;
infile.close();
j++;
s[i]=new stu(name,number, math, cjia, english);
i++;
cout<<"数据录入成功,想继续录入吗(y/n)"<<endl;
cin>>c;
if(c!='y'&&c!='n')
{
cout<<"指令错误!请重新输入!"<<endl;
cin>>c;
}
}while(c=='y');
break;
}
case '2': //删除学生数据
{
char name[20];
double chris2=0;
char c;
do{
cout<<"请输入您要删除的学生姓名:"<<endl;
cin>>name;
for(int h=0;h<i;h++)
{
if(strcmp(name,s[h]->name)==0) //在开始录入的数据中查找名字
{
chris2=1;
i--; //将删除数据后面的数据的脚标变小一位
do{
s[h]=s[h+1]; //用后一个数据覆盖所要删除的数据
h++;
}while(h<=i);
}
}
if(chris2==0)
cout<<"您要求删除的对象本来就不存在!请检查输入的正确性!";
cout<<"要继续删除吗?(y/n)"<<endl;
cin>>c;
if(c!='y'&&c!='n')
{
cout<<"指令错误!请重新输入!"<<endl;
cin>>c;
}
}while(c=='y');
break;
}
case '3': //修改录入的学生数据
{
char name[20];
int num;
double mat,cj,eng;chris1=0;
char c;
do
{
cout<<"请输入您要修改的学生的姓名:"<<endl;
cin>>name;
for(int h=0;h<i;h++)
{
if(strcmp(name,s[h]->name)==0)
{
chris1=1;
cout<<"请输入新的学号:"<<endl;
cin>>num;
cout<<"请输入新的数学成绩:"<<endl;
cin>>mat;
cout<<"请输入新的C++成绩:"<<endl;
cin>>cj;
cout<<"请输入新的英语成绩:"<<endl;
cin>>eng;
s[h]->number=num; //数据的代换
s[h]->cjia=cj;
s[h]->math=mat;
s[h]->english=eng;
cout<<"数据修改成功!";
}
}
if(chris1==0)
{
cout<<"您要修改的学生本来就不存在!请检查重新输入!"<<endl;
}
cout<<"想继续修改吗(y/n)"<<endl;
cin>>c;
if(c!='y'&&c!='n')
{
cout<<"指令错误!请重新输入!"<<endl;
cin>>c;
}
}while(c=='y');
break;
}
case '4': //按总成绩查询
{
double t; //输入的总成绩
char c;
do
{
int chris3=0;
cout<<"请输入你要查询学生的总成绩:"<<endl;
cin>>t;
for(int q=0;q<i;q++)
{
if(s[q]->getsum()==t) //查找符合的总成绩
{
chris3=1;
cout<<"***********你所查询的学生信息如下***********"<<endl;
cout<<"┌————┬——┬————┬————┬————┬——┬————┐"<<endl;
cout<<"│ 姓 名 │学号│ 数 学 │ c++ │ 英语 │总分│ 平均分 │"<<endl;
cout<<"├————┼——┼————┼————┼————┼——┼————┤"<<endl;
cout<<"│"<<setw(8)<<(*s[q]).name<<"│"<<setw(4)<<(*s[q]).number<<"│"<<setw(8)<<(*s[q]).math<<"│"<<setw(8)
<<(*s[q]).cjia<<"│"<<setw(8)<<(*s[q]).english<<"│"<<setw(4)<<(*s[q]).getsum()<<"│"<<setw(8)<<(*s[q]).getaver()<<"│"<<endl;
cout<<"└————┴——┴————┴————┴————┴——┴————┚"<<endl;
}
}
if(chris3==0)
cout<<"对不起!您要查询的学生不存在!"<<endl;
cout<<"您想继续查询吗?(y/n)"<<endl;
cin>>c;
if(c!='y'&&c!='n')
{
cout<<"指令错误!请重新输入!"<<endl;
cin>>c;
}
}
while(c=='y');
break;
}
case '5': //按姓名查找
{
char n[20]; //输入的名字
char c;
do{
int chris=0;
cout<<"请输入你要查询的学生姓名"<<endl;
cin>>n;
for(int m=0;m<i;m++)
{
if(strcmp(n,(*s[m]).name)==0)//查找并输出所要查询的数据
{
chris=1;
cout<<"***********你所查询的学生信息如下***********"<<endl;
cout<<"┌————┬——┬————┬————┬————┬——┬————┐"<<endl;
cout<<"│ 姓 名 │学号│ 数 学 │ c++ │ 英语 │总分│ 平均分 │"<<endl;
cout<<"├————┼——┼————┼————┼————┼——┼————┤"<<endl;
cout<<"│"<<setw(8)<<(*s[m]).name<<"│"<<setw(4)<<(*s[m]).number<<"│"<<setw(8)<<(*s[m]).math<<"│"<<setw(8)
<<(*s[m]).cjia<<"│"<<setw(8)<<(*s[m]).english<<"│"<<setw(4)<<(*s[m]).getsum()<<"│"<<setw(8)<<(*s[m]).getaver()<<"│"<<endl;
cout<<"└————┴——┴————┴————┴————┴——┴————┚"<<endl;
}
}
if(chris==0)
cout<<"对不起!您要查询的学生不存在!"<<endl;
cout<<"您想继续查询吗?(y/n)"<<endl;
cin>>c;
if(c!='y'&&c!='n')
{
cout<<"指令错误!请重新输入!"<<endl;
cin>>c;
}
}
while(c=='y');
break;
}
case '6': //按学号查找
{
int num; //输入的学号
char c;
do{
int chris5=0;
cout<<"请输入你要查询的学生学号:"<<endl;
cin>>num;
for ( int d=0;d<i;d++)
{
if(num==(*s[d]).number)
{
chris5=1;
cout<<"***********你所查询的学生信息如下***********"<<endl;
cout<<"┌————┬——┬————┬————┬————┬——┬————┐"<<endl;
cout<<"│ 姓 名 │学号│ 数 学 │ c++ │ 英语 │总分│ 平均分 │"<<endl;
cout<<"├————┼——┼————┼————┼————┼——┼————┤"<<endl;
cout<<"│"<<setw(8)<<(*s[d]).name<<"│"<<setw(4)<<(*s[d]).number<<"│"<<setw(8)<<(*s[d]).math<<"│"<<setw(8)
<<(*s[d]).cjia<<"│"<<setw(8)<<(*s[d]).english<<"│"<<setw(4)<<(*s[d]).getsum()<<"│"<<setw(8)<<(*s[d]).getaver()<<"│"<<endl;
cout<<"└————┴——┴————┴————┴————┴——┴————┚"<<endl;
}
}
if(chris5==0)
cout<<"对不起!您要查询的学生不存在!"<<endl;
cout<<"您想继续查询吗?(y/n)"<<endl;
cin>>c;
if(c!='y'&&c!='n')
{
cout<<"指令错误!请重新输入!"<<endl;
cin>>c;
}
}
while(c=='y');
break;
}
case '7': //将录入的数据全部输出
{
cout<<"***********本系统所有学生数据如下:***********"<<endl;
if(i==0)
cout<<"管理系统中没有录入数据或者数据已经被删除!"<<endl;
for(int k=0;k<i;k++)
{
cout<<"┌————┬——┬————┬————┬————┬——┬————┐"<<endl;
cout<<"│ 姓 名 │学号│ 数 学 │ c++ │ 英语 │总分│ 平均分 │"<<endl;
cout<<"├————┼——┼————┼————┼————┼——┼————┤"<<endl;
cout<<"│"<<setw(8)<<s[k]->name<<"│"<<setw(4)<<s[k]->number<<"│"<<setw(8)<<s[k]->math<<"│"<<setw(8)
<<s[k]->cjia<<"│"<<setw(8)<<s[k]->english<<"│"<<setw(4)<<(*s[k]).getsum()<<"│"<<setw(8)<<(*s[k]).getaver()<<"│"<<endl;
cout<<"└————┴——┴————┴————┴————┴——┴————┚"<<endl;
}
break;
}
case '8': //计算学生成绩等级及所占比例
{ int a,b,c,d,e;
a=b=c=d=e=0;
for( int f =0;f<3;f++)
switch(f)
{
case 0: //英语成绩等级比例
{
a=b=c=d=e=0;
cout<<"输出英语总平均成绩及优秀,良好,中等,及格,不及格,的人数及其所点比例:"<<endl;
double englishsum=0.0,englishave=0.0;
for ( int g=0;g<i;g++)
{
englishsum+=((*s[g]).english); //计算英语总分
}
englishave=englishsum/g; //计算英语平均分
cout<<"英语的总平均成绩:"<<englishave<<endl;
for (int l=0;l<i;l++)
{
switch(int (s[l]->english/10)) //计算每个等级的人数
{
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:e++;break;
case 6:d++;break;
case 7:c++;break;
case 8:b++;break;
case 9:
case 10:a++;break;
}
}
#include<string.h>
#include<fstream.h>
#include<stdlib.h>
#include<iomanip.h>
class stu //通过定义一个类来定义数据录入的函数
{
char name[20];
int number;
double math,cjia,english,average,sum;
public:
stu()
{};
stu ( char n[20], int num,double ma,double cj,double eng )
{
strcpy(name,n); //得到姓名
number=num; //得到学号
math=ma; //得到数学成绩
cjia=cj; //得到c++成绩
english=eng; //得到英语成绩
}
double getsum() //得到总分的函数
{
sum=cjia+english+math;
return sum;
}
double getaver() //得到平均分的函数
{
average=getsum()/3;
return average;
}
friend void main(); //将主函数定义为友元函数,方便访问类中的成员
};
void main()
{
cout<<"*****************欢迎来到学生成绩查询系统*****************"<<endl;
cout<<"请选择您需要的操作!"<<endl; //菜单的输出
cout<<"操作:"<<endl;
cout<<"(0)数据录入"<<endl;
cout<<"(1)增加学生"<<endl;
cout<<"(2)删除学生"<<endl;
cout<<"(3)修改数据"<<endl;
cout<<"查询:"<<endl;
cout<<"(4)按总成绩查询"<<endl;
cout<<"(5)按姓名查询"<<endl;
cout<<"(6)按学号查询"<<endl;
cout<<"(7)输出所有学生的数据"<<endl;
cout<<"成绩统计:"<<endl;
cout<<"(8)各科平均成绩和各科成绩优秀,良好,中等,及格,不及格,的人数及其所占比例:"<<endl;
cout<<"读取与保存:"<<endl;
cout<<"(9)学生信息的读取与保存:"<<endl;
cout<<"成绩名次:"<<endl;
cout<<"(x)按总分查询排名"<<endl;
cout<<"(y)按英语查询排名"<<endl;
cout<<"(z)按数学查询排名"<<endl;
cout<<"(u)按C++查询排名"<<endl;
cout<<"选择相关操作请输入相对的括号里的阿拉伯数字及字母!"<<endl;
char p; //全局变量,用于选择菜单时的输入
char w; //全局变量,用于在大项中选择是否继续操作
stu *s[100]; //类定义的指针将所录入的数据按类中的形式分别存储
ofstream *file[100];
int i=0; //全局变量,用于做每个录入数据的下标
int j=0;
double chris1=0; //用于判断do—while语句
do //判断输入是否正确
{
cin>>p;
if((p>='0'&&p<='z'))
chris1=1;
else
cout<<"指令错误!请重新输入:"<<endl;
}while(chris1==0);
do{
switch(p)
{
case '0': //数据的录入
{
char c; //用于在小项中选择是否继续操作
char name[20];
int number;
double math,cjia,english;
do{
cout<<"请输入姓名:"<<endl;
cin>>name;
cout<<"请输入学号:"<<endl;
cin>>number;
cout<<"请输入数学成绩:"<<endl;
cin>>math;
cout<<"请输入C++成绩:"<<endl;
cin>>cjia;
cout<<"请输入英语成绩:"<<endl;
cin>>english;
fstream outfile,infile; //作一个文本文档在文件夹中用于显示所录入的数据
outfile.open("f1.txt",ios::out);
if(!file)
{
cout<<"f1.txt can not open.\n";
abort();
}
outfile<<"姓名:"<<name<<"学号:"<<number<<"数学成绩:"<<math<<"C++成绩:"<<cjia<<"外语成绩:"<<english<<endl;
outfile.close();
infile.open("f1.txt",ios::in);
if(!file) //判断文件是否打开
{
cout<<"f1.txt can not open.\n";
abort();
}
char ch;
while(infile.get(ch))
cout<<ch;
cout<<endl;
infile.close();
j++;
s[i]=new stu(name, number,math, cjia, english);
i++;
cout<<"数据录入成功,想继续录入吗(y/n)"<<endl;
cin>>c;
chris1=0;
do{
if(c!='y'&&c!='n')
{
cout<<"指令错误!请重新输入!"<<endl;
cin>>c;
}
else
chris1=1;
}while(chris1==0);
}while(c=='y'); //重复输入
break;
}
case '1': //增加学生数据
{
char name[20];
int number;
double math,cjia,english;
char c;
do
{
cout<<"请输入您要增加的学生的姓名:"<<endl;
cin>>name;
cout<<"请输入你要增加的学生的学号:"<<endl;
cin>>number;
cout<<"请输入数学成绩:"<<endl;
cin>>math;
cout<<"请输入C++成绩:"<<endl;
cin>>cjia;
cout<<"请输入英语成绩:"<<endl;
cin>>english;
fstream outfile,infile;
outfile.open("f2.txt",ios::out);
if(!file)
{
cout<<"f2.txt can not open.\n";
abort();
}
outfile<<"姓名:"<<name<<"学号:"<<number<<"数学成绩:"<<math<<"C++成绩:"<<cjia<<"外语成绩:"<<english<<endl;
outfile.close();
infile.open("f2.txt",ios::in);
if(!file)
{
cout<<"f2.txt can not open.\n";
abort();
}
char h;
while(infile.get(h))
cout<<h;
cout<<endl;
infile.close();
j++;
s[i]=new stu(name,number, math, cjia, english);
i++;
cout<<"数据录入成功,想继续录入吗(y/n)"<<endl;
cin>>c;
if(c!='y'&&c!='n')
{
cout<<"指令错误!请重新输入!"<<endl;
cin>>c;
}
}while(c=='y');
break;
}
case '2': //删除学生数据
{
char name[20];
double chris2=0;
char c;
do{
cout<<"请输入您要删除的学生姓名:"<<endl;
cin>>name;
for(int h=0;h<i;h++)
{
if(strcmp(name,s[h]->name)==0) //在开始录入的数据中查找名字
{
chris2=1;
i--; //将删除数据后面的数据的脚标变小一位
do{
s[h]=s[h+1]; //用后一个数据覆盖所要删除的数据
h++;
}while(h<=i);
}
}
if(chris2==0)
cout<<"您要求删除的对象本来就不存在!请检查输入的正确性!";
cout<<"要继续删除吗?(y/n)"<<endl;
cin>>c;
if(c!='y'&&c!='n')
{
cout<<"指令错误!请重新输入!"<<endl;
cin>>c;
}
}while(c=='y');
break;
}
case '3': //修改录入的学生数据
{
char name[20];
int num;
double mat,cj,eng;chris1=0;
char c;
do
{
cout<<"请输入您要修改的学生的姓名:"<<endl;
cin>>name;
for(int h=0;h<i;h++)
{
if(strcmp(name,s[h]->name)==0)
{
chris1=1;
cout<<"请输入新的学号:"<<endl;
cin>>num;
cout<<"请输入新的数学成绩:"<<endl;
cin>>mat;
cout<<"请输入新的C++成绩:"<<endl;
cin>>cj;
cout<<"请输入新的英语成绩:"<<endl;
cin>>eng;
s[h]->number=num; //数据的代换
s[h]->cjia=cj;
s[h]->math=mat;
s[h]->english=eng;
cout<<"数据修改成功!";
}
}
if(chris1==0)
{
cout<<"您要修改的学生本来就不存在!请检查重新输入!"<<endl;
}
cout<<"想继续修改吗(y/n)"<<endl;
cin>>c;
if(c!='y'&&c!='n')
{
cout<<"指令错误!请重新输入!"<<endl;
cin>>c;
}
}while(c=='y');
break;
}
case '4': //按总成绩查询
{
double t; //输入的总成绩
char c;
do
{
int chris3=0;
cout<<"请输入你要查询学生的总成绩:"<<endl;
cin>>t;
for(int q=0;q<i;q++)
{
if(s[q]->getsum()==t) //查找符合的总成绩
{
chris3=1;
cout<<"***********你所查询的学生信息如下***********"<<endl;
cout<<"┌————┬——┬————┬————┬————┬——┬————┐"<<endl;
cout<<"│ 姓 名 │学号│ 数 学 │ c++ │ 英语 │总分│ 平均分 │"<<endl;
cout<<"├————┼——┼————┼————┼————┼——┼————┤"<<endl;
cout<<"│"<<setw(8)<<(*s[q]).name<<"│"<<setw(4)<<(*s[q]).number<<"│"<<setw(8)<<(*s[q]).math<<"│"<<setw(8)
<<(*s[q]).cjia<<"│"<<setw(8)<<(*s[q]).english<<"│"<<setw(4)<<(*s[q]).getsum()<<"│"<<setw(8)<<(*s[q]).getaver()<<"│"<<endl;
cout<<"└————┴——┴————┴————┴————┴——┴————┚"<<endl;
}
}
if(chris3==0)
cout<<"对不起!您要查询的学生不存在!"<<endl;
cout<<"您想继续查询吗?(y/n)"<<endl;
cin>>c;
if(c!='y'&&c!='n')
{
cout<<"指令错误!请重新输入!"<<endl;
cin>>c;
}
}
while(c=='y');
break;
}
case '5': //按姓名查找
{
char n[20]; //输入的名字
char c;
do{
int chris=0;
cout<<"请输入你要查询的学生姓名"<<endl;
cin>>n;
for(int m=0;m<i;m++)
{
if(strcmp(n,(*s[m]).name)==0)//查找并输出所要查询的数据
{
chris=1;
cout<<"***********你所查询的学生信息如下***********"<<endl;
cout<<"┌————┬——┬————┬————┬————┬——┬————┐"<<endl;
cout<<"│ 姓 名 │学号│ 数 学 │ c++ │ 英语 │总分│ 平均分 │"<<endl;
cout<<"├————┼——┼————┼————┼————┼——┼————┤"<<endl;
cout<<"│"<<setw(8)<<(*s[m]).name<<"│"<<setw(4)<<(*s[m]).number<<"│"<<setw(8)<<(*s[m]).math<<"│"<<setw(8)
<<(*s[m]).cjia<<"│"<<setw(8)<<(*s[m]).english<<"│"<<setw(4)<<(*s[m]).getsum()<<"│"<<setw(8)<<(*s[m]).getaver()<<"│"<<endl;
cout<<"└————┴——┴————┴————┴————┴——┴————┚"<<endl;
}
}
if(chris==0)
cout<<"对不起!您要查询的学生不存在!"<<endl;
cout<<"您想继续查询吗?(y/n)"<<endl;
cin>>c;
if(c!='y'&&c!='n')
{
cout<<"指令错误!请重新输入!"<<endl;
cin>>c;
}
}
while(c=='y');
break;
}
case '6': //按学号查找
{
int num; //输入的学号
char c;
do{
int chris5=0;
cout<<"请输入你要查询的学生学号:"<<endl;
cin>>num;
for ( int d=0;d<i;d++)
{
if(num==(*s[d]).number)
{
chris5=1;
cout<<"***********你所查询的学生信息如下***********"<<endl;
cout<<"┌————┬——┬————┬————┬————┬——┬————┐"<<endl;
cout<<"│ 姓 名 │学号│ 数 学 │ c++ │ 英语 │总分│ 平均分 │"<<endl;
cout<<"├————┼——┼————┼————┼————┼——┼————┤"<<endl;
cout<<"│"<<setw(8)<<(*s[d]).name<<"│"<<setw(4)<<(*s[d]).number<<"│"<<setw(8)<<(*s[d]).math<<"│"<<setw(8)
<<(*s[d]).cjia<<"│"<<setw(8)<<(*s[d]).english<<"│"<<setw(4)<<(*s[d]).getsum()<<"│"<<setw(8)<<(*s[d]).getaver()<<"│"<<endl;
cout<<"└————┴——┴————┴————┴————┴——┴————┚"<<endl;
}
}
if(chris5==0)
cout<<"对不起!您要查询的学生不存在!"<<endl;
cout<<"您想继续查询吗?(y/n)"<<endl;
cin>>c;
if(c!='y'&&c!='n')
{
cout<<"指令错误!请重新输入!"<<endl;
cin>>c;
}
}
while(c=='y');
break;
}
case '7': //将录入的数据全部输出
{
cout<<"***********本系统所有学生数据如下:***********"<<endl;
if(i==0)
cout<<"管理系统中没有录入数据或者数据已经被删除!"<<endl;
for(int k=0;k<i;k++)
{
cout<<"┌————┬——┬————┬————┬————┬——┬————┐"<<endl;
cout<<"│ 姓 名 │学号│ 数 学 │ c++ │ 英语 │总分│ 平均分 │"<<endl;
cout<<"├————┼——┼————┼————┼————┼——┼————┤"<<endl;
cout<<"│"<<setw(8)<<s[k]->name<<"│"<<setw(4)<<s[k]->number<<"│"<<setw(8)<<s[k]->math<<"│"<<setw(8)
<<s[k]->cjia<<"│"<<setw(8)<<s[k]->english<<"│"<<setw(4)<<(*s[k]).getsum()<<"│"<<setw(8)<<(*s[k]).getaver()<<"│"<<endl;
cout<<"└————┴——┴————┴————┴————┴——┴————┚"<<endl;
}
break;
}
case '8': //计算学生成绩等级及所占比例
{ int a,b,c,d,e;
a=b=c=d=e=0;
for( int f =0;f<3;f++)
switch(f)
{
case 0: //英语成绩等级比例
{
a=b=c=d=e=0;
cout<<"输出英语总平均成绩及优秀,良好,中等,及格,不及格,的人数及其所点比例:"<<endl;
double englishsum=0.0,englishave=0.0;
for ( int g=0;g<i;g++)
{
englishsum+=((*s[g]).english); //计算英语总分
}
englishave=englishsum/g; //计算英语平均分
cout<<"英语的总平均成绩:"<<englishave<<endl;
for (int l=0;l<i;l++)
{
switch(int (s[l]->english/10)) //计算每个等级的人数
{
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:e++;break;
case 6:d++;break;
case 7:c++;break;
case 8:b++;break;
case 9:
case 10:a++;break;
}
}
展开全部
定义一个分数管理的类,类中包括一些诸如学生信息,课程信息,成绩等内容
利用STL里边的vector是比较容易实现的
具体的管理,诸如添加删除,排序什么的,vector里有现成的函数
这种小工程性质的东西,还是自己写比较靠谱,下面回答的,多数是copy的代码,估计和你的要求风马牛不相及,不要什么东西都想着别人帮你写(当然,你若愿意付费,会写的人还是有的,比如我,百度的100分,。。那还是算了吧,不会有人真正稀罕这种东西的)
利用STL里边的vector是比较容易实现的
具体的管理,诸如添加删除,排序什么的,vector里有现成的函数
这种小工程性质的东西,还是自己写比较靠谱,下面回答的,多数是copy的代码,估计和你的要求风马牛不相及,不要什么东西都想着别人帮你写(当然,你若愿意付费,会写的人还是有的,比如我,百度的100分,。。那还是算了吧,不会有人真正稀罕这种东西的)
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
楼上的说的好啊
这种小工程性质的东西,还是自己写比较靠谱
不过vector里面没有排序的函数吧……
这种小工程性质的东西,还是自己写比较靠谱
不过vector里面没有排序的函数吧……
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
楼上说的对啊!
顶!
顶!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询