jiguangdi @ 2023-10-13 21:38:39
#include<string>
using namespace std;
int main(){
int a,b[1000],c[1000],d[1000],i=0,f[1000],z;
cin>>a;
string e[1000];
while(a--)
{
cin>>e[i]>>b[i]>>c[i]>>d[i];
f[i]=b[i]+c[i]+d[i];
i++;
}
for(int k=1;k<=a;k++)
{
if(f[0]<f[k])
{
f[0]=f[k];
z=k;
}
}
cout<<e[z]<<b[z]<<c[z]<<d[z];
return 0;
}
by NO_OI_NO_LIFE @ 2023-10-13 21:45:58
你这是CE,头文件的问题
by heyx0201 @ 2023-10-13 21:47:52
@jiguangdi 《RE = CE》
您用 C++ 输入输出流不开头文件的吗?
by CSP_SWINNER1130 @ 2023-10-13 21:49:41
有点抽象,数组定义在主函数内还开小了
by NO_OI_NO_LIFE @ 2023-10-13 21:53:49
你代码错误太多了,这是你的,我改了半天还不对(RE
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b[1000],c[1000],d[1000],i=0,f[1000],z;
cin>>a;
string e[1000];
int v=a;
while(a--)
{
i++;
cin>>e[i]>>b[i]>>c[i]>>d[i];
f[i]=b[i]+c[i]+d[i];
i++;
}
f[0]=0x3f3f3f3f;
for(int k=1;k<=v;k++)
{
if(f[0]<f[k])
{
f[0]=f[k];
z=k;
}
}
cout<<e[z]<<" "<<b[z]<<" "<<c[z]<<" "<<d[z];
return 0;
}
这是我的
#include <bits/stdc++.h>
using namespace std;
int n,ans=-1,anss,ansss,anssss,mn;
string nm[1005];
int a,b,c;
int main(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>nm[i]>>a>>b>>c;
if(a+b+c>ans)
ans=a+b+c,mn=i,anss=a,ansss=b,anssss=c;
}
cout<<nm[mn]<<" "<<anss<<" "<<ansss<<" "<<anssss;
return 0;
}
by jiguangdi @ 2023-10-13 22:47:42
@heyx0201 我忘了复制,对不起了
by heyx0201 @ 2023-10-13 22:48:54
@2022zhangyuanhao 你就没发现他数组开小了吗。。
by jiguangdi @ 2023-10-13 22:50:30
@K_cp2312 佬那个是不是数组需要在int main(){}的前面
by heyx0201 @ 2023-10-13 22:53:03
@jiguangdi 帮你改成了这样,RE变成了WA(
#include <bits/stdc++.h>
using namespace std;
int main() {
int a, b[1001], c[1001], d[1001], i = 0, f[1001], z;
cin >> a;
string e[1001];
int v = a;
while (a--) {
i++;
cin >> e[i] >> b[i] >> c[i] >> d[i];
f[i] = b[i] + c[i] + d[i];
}
f[0] = 0x3f3f3f3f;
for (int k = 1; k <= v; k++) {
if (f[0] < f[k]) {
f[0] = f[k];
z = k;
}
}
cout << e[z] << " " << b[z] << " " << c[z] << " " << d[z];
return 0;
}
by jiguangdi @ 2023-10-13 22:55:06
@heyx0201 我刚又变大了,还是RE,然后我数组还开到外面了
by NO_OI_NO_LIFE @ 2023-10-13 22:55:59
@heyx0201 像极了以前的我