您的位置:首页 > 其它

PTA练习题.高考状元

2017-06-26 20:31 204 查看
#include<iostream>
#include<string>
using namespace std;
class student
{
double yuwen;//语文
double math;//数学
double english;//英语
double zong;//综合
public:
string name;
void set(string name1,double yuwen1,double math1,double english1,double zong1)
{
name=name1;
yuwen=yuwen1;
math=math1;
english=english1;
zong=zong1;
}
friend student top(const student *p,int count)
{
double sum=0,tp=0;
int q;
for(int i=0;i<count;i++)
{
tp=p[i].yuwen+p[i].math+p[i].english+p[i].zong;
if(sum<tp)
sum=tp;
}
cout<<sum;
return p[q];
}
};
int main()
{
string name;
double yuwen1;
double math1;
double english1;
double zong1;
double topp;
student a[100];
int i=0;
while(1)
{
cin>>name;
if(name!="0")
{
cin>>yuwen1>>math1>>english1>>zong1;
a[i++].set(name,yuwen1,math1,english1,zong1);
}
else
break;
}
top(a,i);
return 0;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: