为什么WA了

P5740 【深基7.例9】最厉害的学生

_Hero_ @ 2021-10-17 11:28:34

c++WA一个点

#include<bits/stdc++.h>
using namespace std;
struct xs{
string mz;
int yw,sx,yy;   
}a,s;
int main()
{
    int n=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
    cin>>a.mz>>a.yw>>a.sx>>a.yy;
    if(a.yw+a.sx+a.yy>s.yw+s.yy+s.sx)
    s=a;
    }
    cout<<s.mz<<" "<<s.yw<<" "<<s.sx<<" "<<s.yy;
    return 0;
}

by wyp001 @ 2021-10-17 11:30:55

???,题号


by wyp001 @ 2021-10-17 11:33:25

噢,可能交题解的吧,要么跟题解写的太像。


by _Hero_ @ 2021-10-17 11:34:10

@wyp001 P5740 右边有


by THRONESEAL @ 2021-10-17 11:34:15

总分有可能相同,要用序号来排


by shucai @ 2021-10-17 11:34:25

#include<bits/stdc++.h>
using namespace std;
struct xs{
string mz;
int yw,sx,yy;   
}a,s;
int main()
{
    int n=0;
    cin>>n;
    s.yw = s.yy = s.sx = -1;
    for(int i=0;i<n;i++)
    {
    cin>>a.mz>>a.yw>>a.sx>>a.yy;
    if(a.yw+a.sx+a.yy>s.yw+s.yy+s.sx)
    s=a;
    }
    cout<<s.mz<<" "<<s.yw<<" "<<s.sx<<" "<<s.yy;
    return 0;
}

by shucai @ 2021-10-17 11:34:48

@学生党立哥


by THRONESEAL @ 2021-10-17 11:36:07

最好还是开个数组


by wyp001 @ 2021-10-17 11:36:10

有一些模板题很容易出现,


by _Hero_ @ 2021-10-17 11:38:28

我看深入浅出学的,刚学15分钟,谢谢各位


|