边读入,边处理,不需要保存数据

 

#include<cstdio>
#include<cstring>
char name[100],sname[100];
int main(){
    int n,score,maxn=-1;
    scanf("%d",&n);
    for (int i=1;i<=n;i++){
        scanf("%d%s",&score,name);
        if (score>maxn) {
            maxn=score;
            strcpy(sname,name);
        }
    }
    printf("%s",sname);
    return 0;
}
View Code