audvnj @ 2023-07-19 12:25:37
#include<bits/stdc++.h>
using namespace std;
int n[301];
struct qwert
{
int x;
int y;
int s;
int e;
int z(){
return y+s+e;
}
};
bool cmp(int a,int b)
{
return a>b;
}
int main()
{
qwert a;
int b;
cin>>b;
for(int i=1;i<=b;i++)
{
cin>>a.x >>a.y >>a.s>>a.e;
}
for(int i=1;i<=b;i++)
{
sort(a.z(),a.z(),cmp);
}
for(int i=1;i<=b;i++)
{
cout<<a.x <<' '<<a.z() ;
}
}
by FengYuXinMing @ 2023-07-19 12:32:53
你不加下标不报错才怪好吗?
by FengYuXinMing @ 2023-07-19 12:33:26
tmd,报错信息吓我一跳,你这是把源码炸出来了
by LgxTpre @ 2023-07-19 12:33:42
@audvnj 你的sort太逆天了
by LgxTpre @ 2023-07-19 12:34:00
@ababbjxzt 主要原因不是这个吧
by LgxTpre @ 2023-07-19 12:35:37
@audvnj 这样好了
#include<bits/stdc++.h>
using namespace std;
int n[301];
struct qwert
{
int x;
int y;
int s;
int e;
int z(){
return y+s+e;
}
};
int main()
{
qwert a[1000];
int b;
cin>>b;
for(int i=1;i<=b;i++)
{
cin>>a[i].x >>a[i].y >>a[i].s>>a[i].e;
}
sort(a+1,a+b+1,[&](qwert x,qwert y){return x.z()<y.z();});
for(int i=1;i<=b;i++)
{
cout<<a[i].x <<' '<<a[i].z() ;
}
}
by audvnj @ 2023-07-19 12:37:46
@ababbjxzt 下标......, 不要问:你不会..., 。。。。我要是知道怎么改...
by FengYuXinMing @ 2023-07-19 12:38:00
@LgxTpre sort逆天,cmp函数让人心跳骤停,下标又不加,定义结构体a又不告诉定义了多少个,我不仔细看就以为只有一个下标没加,我一改代码,直接血压飙升
by FengYuXinMing @ 2023-07-19 12:38:51
@audvnj ?
by LgxTpre @ 2023-07-19 12:39:12
@ababbjxzt 你说的很对
by audvnj @ 2023-07-19 12:40:20
@ababbjxzt 我改改