谁能看看错哪了???

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

JackHu0117 @ 2022-03-18 13:25:05

#include<iostream>
#include<cstdio>
#include<cstring>
#include<math.h>
using namespace std;
int a;
int x,y,z;
int max1=0;
char A[32],B[32];
int m[3];
int qh(int a,int b,int c){
    int k=a+b+c;
    return k;
}

int main(){
    cin>>a;
    for(int i=0;i<a;i++){
        scanf("%s %d %d %d",A,&x,&y,&z);
        int k=qh(x,y,z);
        if(k>max1){
            max1=k;
            strcpy(B,A);
            m[0]=x;
            m[1]=y;
            m[2]=z;
        }
    }
    int f=strlen(B);
    for(int i=0;i<f;i++){
        cout<<B[i];
    }
    cout<<' '<<m[0]<<' '<<m[1]<<' '<<m[2]<<endl;
    return 0;
}

by zxy123bc @ 2022-03-18 13:39:45

@JackHu0117

maxn设为-1

(要不然全是0maxn不会更新)


by JackHu0117 @ 2022-03-18 14:23:45

谢谢


|