幽梦蓝殇 @ 2017-05-06 13:34:23
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
int a[99][99],n,b[99][99]={0},x=0,j,i,m,shu=0;
cin>>n;
for(int i=1;i<=n;++i)
{
for(int j=1;j<=3;++j)
cin>>a[i][j];
}
for(int i=1;i<=n;++i)
{
for(int j=1;j<=3;++j)
b[i][2]+=a[i][j];
}
for(int i=1;i<=n;++i)
b[i][1]=i;
for(int j=1;j<=n-1;++j)
{
for(int i=1;i<=n-j;++i)
if(b[i][2]<=b[i+1][2])
{
x=b[i][2];
b[i][2]=b[i+1][2];
b[i+1][2]=x;
shu=b[i][1];
b[i][1]=b[i+1][1];
b[i+1][1]=shu;
}
}
for(int i=1;i<=5;++i)
{
for(int j=1;j<=2;++j)
cout<<b[i][j]<<" ";
cout<<endl;
}
}
by 蒟蒻lxy @ 2017-05-12 13:40:37
by 蒟蒻lxy @ 2017-05-14 12:40:17
sort的cmp:
bool cmp(node a,node b)
{
if(a.zf!=b.zf)return a.zf>b.zf;
if(a.yw!=b.yw)return a.yw>b.yw;
return a.xh<b.xh;
}