90分求助!

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

ZS_Lichi @ 2023-12-17 14:28:02

大佬们,90分求助!```

第一个点没过

#include <bits/stdc++.h>
using namespace std;
struct student {
    string name;
    int chinese,math,english;
}a,ans;
int main(){
    int n;
    cin >> n;
    for(int i = 2;i <= n;i++){
        cin >> a.name >> a.chinese >>a.math >> a.english;
        if(a.chinese + a.math + a.english > ans.chinese + ans.math + ans.english){
            ans = a;
        }
    }
    cout << ans.name <<" " <<  ans.chinese << " "<< ans.math << " " << ans.english <<endl;
    return 0;
}

by ylch @ 2023-12-17 15:07:47

循环里i为什么从2开始呢?


by ZS_Lichi @ 2023-12-24 14:08:20

@ylch 爱你♥


by ylch @ 2023-12-24 17:25:46

不客气ヾ(•ω•`)o


by ZS_Lichi @ 2023-12-31 13:58:23

大佬还是不对怎么办


by mingmax @ 2024-01-03 13:19:10

书上的代码int i=1;也是90分,第一个wa了


by ZS_Lichi @ 2024-01-24 13:14:45

@mingmax 是的


by anlinjie @ 2024-02-22 13:06:48

@RC_CD_1024_NF 怎么解决的,我也是第一个wa


by ZS_Lichi @ 2024-02-24 18:44:21

@anlinjie 没解决


by ZS_Lichi @ 2024-02-24 18:46:06

@anlinjie 过了,循环i改成了1


by anlinjie @ 2024-02-25 10:50:01

@RC_CD_1024_NF 搜嘎


|