Oye0ye @ 2022-05-23 16:03:29
#include<bits/stdc++.h>
using namespace std;
struct stu{
string x;
long long y;
long long z;
long long d;
};
int main(){
long long n,s[10000],max=0,l;
cin>>n;
long long i;
stu a[10000];
for(i=1;i<=n;i++)
{
cin>>a[i].x>>a[i].y>>a[i].z>>a[i].d;
s[i]=a[i].y+a[i].z+a[i].d;
}
for(i=1;i<=n;i++)
{
if(s[i]>max)
{
max=s[i];
l=i;
}
}
cout<<a[l].x<<" "<<a[l].y<<" "<<a[l].z<<" "<<a[l].d;
return 0;
}
by ivyjiao @ 2022-05-23 16:19:21
@oyeoye 第一个点所有学生均为0分,max得初始化-1。
#include<iostream>
using namespace std;
struct stu{
string x;
long long y;
long long z;
long long d;
};
long long n,s[100000],maxn=-1,l;
long long i;
stu a[100000];
int main(){
cin>>n;
for(i=1;i<=n;i++)
{
cin>>a[i].x>>a[i].y>>a[i].z>>a[i].d;
s[i]=a[i].y+a[i].z+a[i].d;
}
for(i=1;i<=n;i++)
{
if(s[i]>maxn)
{
maxn=s[i];
l=i;
}
}
cout<<a[l].x<<" "<<a[l].y<<" "<<a[l].z<<" "<<a[l].d;
return 0;
}
by Oye0ye @ 2022-05-23 16:25:04
太感谢了