hyb2003 @ 2019-10-05 19:10:46
#include<iostream>
#include<cstdio>
using namespace std;
int h[301],c[301],z[301];
int main()
{
int n,e,m;
scanf("%d",&n);
for(int i=1;i<n;i++)
{
scanf("%d %d %d ",&c[i],&m,&e);
h[i]=c[i]+m+e;
z[i]=i;
}
for(int i=1;i<n-1;i++)
{
if(h[i]<h[i+1])
{
swap(h[i],h[i+1]);
swap(c[i],c[i+1]);
swap(z[i],z[i+1]);
}
else if(h[i]==h[i+1]&&c[i]<c[i+1])
{
swap(h[i],h[i+1]);
swap(c[i],c[i+1]);
swap(z[i],z[i+1]);
}
else if(h[i]==h[i+1]&&c[i]==c[i+1]&&z[i]>z[i+1])
{
swap(h[i],h[i+1]);
swap(c[i],c[i+1]);
swap(z[i],z[i+1]);
}
}
for(int i=1;i<=5;i++)
{
cout<<z[i]<<" "<<h[1]<<endl;
}
return 0;
}
by Zxx200611 @ 2019-10-05 19:19:21
@hyb2003 这是冒泡么,冒泡好像是要两层循环的吧
by legendgod @ 2019-10-05 19:36:10
确实是双重循环
for(int i=1;i<n-1;i++)
for(int j=1;j<n-1;j++)