帮本蒟蒻debug

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

shangyuang @ 2022-06-30 19:48:44

code:

#include<bits/stdc++.h>
using namespace std;
int n,a,max1=INT_MIN,io;
struct student{
    string name;
    int yw;
    int sx;
    int yy;

}s[1001];
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        getline(cin,s[i].name);
        cin>>s[i].yw>>s[i].sx>>s[i].yy;

    }
    for(int i=n;i>=1;i--){
         if(max1<=s[i].yw+s[i].sx+s[i].yy){
             io=i;
             max1=s[i].yw+s[i].sx+s[i].yy;
        }
    }
        cout<<s[io].name<<' '<<s[io].yw<<' '<<s[io].sx<<' '<<s[io].yy;

        return 0;
}


by zhujunting @ 2022-07-09 14:58:48

神奇(doge)


上一页 |