qwerzxjj @ 2022-01-20 22:21:52
#include<stdio.h>
#include<algorithm>
struct stu{
int a;
int b;
int c;
int num;
int sum;
}Stu[100];
bool cmp(stu m,stu n)
{
if(m.sum!=n.sum)
return m.sum>n.sum;
else if(m.a!=n.a)
return m.a>n.a;
else
return m.num<n.num;
}
int main()
{
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
Stu[i].num=i;
scanf("%d %d %d",&Stu[i].a,&Stu[i].b,&Stu[i].c);
Stu[i].sum+=Stu[i].a+Stu[i].b+Stu[i].c;
}
sort(Stu+1,Stu+1+n,cmp);
for(int i=1;i<=n;i++)
{
printf("%d %d",i,Stu[i].sum);
}
return 0;
}
by ud2_ @ 2022-01-20 22:25:14
std::sort
.
by QcpyWcpyQ @ 2022-01-20 22:25:53
可能要std::
by hjl2011 @ 2022-01-20 22:39:43
@qwerzxjj
using
namespace
std;
无语排版
by hjl2011 @ 2022-01-20 22:40:39
注:请自行放置一行,洛谷的检查有点无语
by qwerzxjj @ 2022-01-20 23:23:17
感谢各位大佬