当前位置:网站首页>PTA:7-63 计算高考状元
PTA:7-63 计算高考状元
2022-06-23 03:47:00 【Sy_Faker】
高考成绩已经公布,大家正在填报志愿。设计一个学生类student,四门学科成绩是其私有成员,分别是语文、数学、英语、综合。有个计算高考状元的函数是其友元函数,其形式是 student top(const student *p, int count) 。
以上类名和友元函数的形式,均须按照题目要求,不得修改。
输入是姓名 和 四科成绩,以0结束。 (不超过100个学生) 输出是状元的总分。
输入样例:
Alice 105 107 107 230
Bob 112 120 120 250
0
输出样例:
602
#include<iostream>
#include<cstring>
using namespace std;
class student
{
private:
int chinese;
int math;
int english;
int mix;
public:
student()
{
;
}
void input(int c,int m,int e,int mi)
{
chinese=c;
math=m;
english=e;
mix=mi;
}
int sum()const
{
return chinese+math+english+mix;
}
friend student top(const student *p,int count);
};
student top (const student *p,int count)
{
int max=0,s;
for(int i=0;i<count;i++)
{
s=p[i].sum();
max=max>s?max:s;
}
cout<<max<<endl;
return *p;
}
int main()
{
char name[10];
int a,b,c,d;
student p[100];
int i=0;
while(1)
{
cin>>name;
if(strcmp(name,"0")==0)
break;
cin>>a>>b>>c>>d;
p[i++].input(a,b,c,d);
getchar();
}
top (p,i);
}
边栏推荐
- PTA: spacing of 7-69 data
- 【深度学习】深度学习推理框架 TensorRT MNN OpenVINO ONNXRuntime
- 在 KubeSphere 上部署 Apache Pulsar
- [advanced binary tree] AVLTree - balanced binary search tree
- Why APP But Not WebPage
- 静态查找表和静态查找表
- mysql存储引擎之Myisam和Innodb的区别
- Prince language under insect date category
- 自媒体时代的贤内助——AI 视频云
- Twitter与Shopify合作 将商家产品引入Twitter购物当中
猜你喜欢
随机推荐
靜態查找錶和靜態查找錶
Create a desktop shortcut to your appimage
How to make the page number start from the specified page in word
如何保证应用程序的安全性
【深度学习】深度学习推理框架 TensorRT MNN OpenVINO ONNXRuntime
MySQL data recovery (.Ibdata1, bin log)
Differences between MyISAM and InnoDB of MySQL storage engine
P1363 幻象迷宫(dfs)
移动端城市列表排序js插件vercitylist.js
Review the SQL row column conversion, and the performance has been improved
There is a problem with redis startup
Inscription of lougu brush
Similar to RZ / SZ, trzsz supporting TMUX has released a new version
华为联机对战服务玩家快速匹配后,不同玩家收到的同一房间内玩家列表不同
Pytoch --- pytoch customizes the dataset
Why APP But Not WebPage
mysql存储引擎之Myisam和Innodb的区别
Prince language on insect date class
在线文本过滤小于指定长度工具
Redis启动有问题
![[deep learning] deep learning reasoning framework tensorrt MNN openvino onnxruntime](/img/a9/11bc00a91b79358f28ada2d4c99f32.png)








