LRXXXM @ 2021-11-09 16:55:55
我第一个点RE了
#include<bits/stdc++.h>
using namespace std;
struct ss{
string name;
int a,b,c,d;;
};
int main()
{
ss s[1005];
int n,mark,max=0,tmp;
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>s[i].name>>s[i].a>>s[i].b>>s[i].c;
tmp=s[i].a+s[i].b+s[i].c;
if(tmp>max)
{
max=tmp;
mark=i;
}
}
cout<<s[mark].name<<" "<<s[mark].a<<" ";
cout<<s[mark].b<<" "<<s[mark].c;
return 0;
}
by Echidna @ 2021-11-09 17:19:16
@LRXXXM 如果所有人三科全是
改了就能 A
by _Haoomff_ @ 2021-11-09 17:23:35
@LRXXXM tmp每次用好要归0
by _Haoomff_ @ 2021-11-09 17:24:56
@LRXXXM
for(int i=1;i<=n;i++)
{
cin>>s[i].name>>s[i].a>>s[i].b>>s[i].c;
tmp=s[i].a+s[i].b+s[i].c;
if(tmp>max)
{
max=tmp;
mark=i;
}
}
改为
for(int i=1;i<=n;i++)
{
cin>>s[i].name>>s[i].a>>s[i].b>>s[i].c;
tmp=s[i].a+s[i].b+s[i].c;
if(tmp>max)
{
max=tmp;
mark=i;
}
tmp=0;
}
by Echidna @ 2021-11-09 17:35:01
@L_YALONG 归零没意义,毕竟每次一上来都要重新赋值
by _Haoomff_ @ 2021-11-10 17:33:31
@某学oi的蒟蒻 你结构体里打了两个分号
by Echidna @ 2021-11-10 19:22:41
@L_YALONG 单个独立的分号会被识别为一个语句
所以没有影响。 比如我写这样的东西就可以过编译
int main(){
{{{{;;;};};};};;;
{{
;;
{{
;{;};
}}
}}
}
by _Haoomff_ @ 2021-11-11 17:31:58
@某学oi的蒟蒻 长知识了
by zzyxl_qaq @ 2021-12-11 18:42:55
同一点re
#include<bits/stdc++.h>
using namespace std;
struct S{
string nam;
int aa,b,c,al;
};
int main(){
int n,maxn=0,maxnn;
cin>>n;
S a[n];
for(int i=0;i<n;i++){
cin>>a[i].nam>>a[i].aa>>a[i].b>>a[i].c;
a[i].al=a[i].aa+a[i].b+a[i].c;
}
for(int i=0;i<n;i++){
if(a[i].al>maxn){
maxn=a[i].al;
maxnn=i;
}
}
cout<<a[maxnn].nam<<" "<<a[maxnn].aa<<" "<<a[maxnn].b<<" "<<a[maxnn].c;
}
by Nevergonna_CCF @ 2021-12-21 16:17:41
一样
#include <iostream>
#include <algorithm>
using namespace std;
struct student{
string name;
int c,e,m;
}s[101];
bool cmp(student a, student b){
return (a.c+a.e+a.m)>(b.c+b.e+b.m);
}
int main(){
int n;
cin >> n;
for(int i = 0; i < n; i++){
cin >> s[i].name >> s[i].c >> s[i].e >> s[i].m;
}
sort(s,s+n,cmp);
cout << s[0].name << " " << s[0].c << " " << s[0].e << " " << s[0].m;
return 0;
}
by Nevergonna_CCF @ 2021-12-21 16:18:46
全部RE