BEAR_ABSURD @ 2023-12-28 15:04:32
#include<stdio.h>
int main(){
char a,a1;
int n,i,j,s,ch,ch1;
int ma,ma1,es,es1,maxn=-1;
scanf("%d",&n);
for(i=1;i<=n;i++){
scanf("%s%d%d%d",&a,&ch,&ma,&es);
int s=ch+ma+es;
if(s>maxn){
a1=a;
maxn=s;
ch1=ch;
ma1=ma;
es1=es;
}
}
printf("%s %d %d %d",a1,ch1,ma1,es1);
return 0;
}
by GSPLXM @ 2023-12-28 15:32:36
@BEAR_ABSURD 你的循环是干嘛的 我没看明白他有啥用 我也是蒟蒻
by a_tianfy @ 2023-12-28 22:03:40
有没有一可能名字是字符串
by lpk1118 @ 2024-01-01 21:06:35
@BEAR_ABSURD 名字应该要用字符串吧
by H2330819074 @ 2024-01-30 15:35:54
#include<stdio.h>
#include<string.h>
int main(){
char a1[1002];
char a[1002];
int n,i,j,s,ch,ch1;
int ma,ma1,es,es1,maxn=-1;
scanf("%d",&n);
scanf("%s%d%d%d",a,&ch,&ma,&es);
strcpy(a1,a);
for(i=1;i<=n-1;i++){
s=ch+ma+es;
if(s>maxn || s==maxn && strcmp(a,a1)<0){
strcpy(a1,a);
maxn=s;
ch1=ch;
ma1=ma;
es1=es;
}
scanf("%s%d%d%d",a,&ch,&ma,&es);
}
s=ch+ma+es;
if(s>maxn || s==maxn && strcmp(a,a1)<0){
strcpy(a1,a);
maxn=s;
ch1=ch;
ma1=ma;
es1=es;
}
printf("%s %d %d %d",a1,ch1,ma1,es1);
return 0;
}
帮你改了一下,得了80,里面蕴含的知识点值得你消化消化,至于20分我不知道错哪,但总体思路是可以的
by H2330819074 @ 2024-01-30 16:38:21
@BEAR_ABSURD 刚刚我想复杂了,依据你的代码,我做出了相应的修改,全AC了```c
int main(){ char a1[1002]; char a[1002];//字符串,用于储存名字 ,所以用数组 int n,i,j,s,ch,ch1; int ma,ma1,es,es1,maxn=-1; scanf("%d",&n); scanf("%s%d%d%d",a,&ch,&ma,&es);//a,而不是&a,是因为这是字符串的输入规则 for(i=1;i<=n-1;i++){ s=ch+ma+es; if(s>maxn){ strcpy(a1,a); maxn=s; ch1=ch; ma1=ma; es1=es; } scanf("%s%d%d%d",a,&ch,&ma,&es); } s=ch+ma+es; if(s>maxn){ strcpy(a1,a); maxn=s; ch1=ch; ma1=ma; es1=es; } printf("%s %d %d %d",a1,ch1,ma1,es1); return 0;
}
by H2330819074 @ 2024-01-30 16:40:22
@BEAR_ABSURD 全正确的代码如下:```c
#include<stdio.h>
#include<string.h>
int main(){
char a1[1002];
char a[1002];//字符串,用于储存名字 ,所以用数组
int n,i,j,s,ch,ch1;
int ma,ma1,es,es1,maxn=-1;
scanf("%d",&n);
scanf("%s%d%d%d",a,&ch,&ma,&es);//a,而不是&a,是因为这是字符串的输入规则
for(i=1;i<=n-1;i++){
s=ch+ma+es;
if(s>maxn){
strcpy(a1,a);
maxn=s;
ch1=ch;
ma1=ma;
es1=es;
}
scanf("%s%d%d%d",a,&ch,&ma,&es);
}
s=ch+ma+es;
if(s>maxn){
strcpy(a1,a);
maxn=s;
ch1=ch;
ma1=ma;
es1=es;
}
printf("%s %d %d %d",a1,ch1,ma1,es1);
return 0;
}