讨论 / AC50题纪念
all blue 2014-03-22 18:10:04
点我顶贴 收藏 删除
#include<stdio.h>

struct node

{

int num;

int yu,shu,wai;

int all;

};

int main()

{

int n;

node a[1001];

scanf("%d",&n);

for (int i=1;i<=n;i++)

{

scanf("%d%d%d",&a[i].yu,&a[i].shu,&a[i].wai);

a[i].num=i;

a[i].all=a[i].yu+a[i].shu+a[i].wai;

}

for (int i=1;i<=n;i++)

for (int j=i+1;j<=n;j++)

{

if (a[j].all>a[i].all) {node s=a[j];a[j]=a[i];a[i]=s;}

else

{

if (a[j].all==a[i].all)

{

if (a[j].yu>a[i].yu) {node s=a[j];a[j]=a[i];a[i]=s;}

else

if (a[j].yu==a[i].yu)

{

if(a[j].num<a[i].num)

{node s=a[j];a[j]=a[i];a[i]=s;}

}

}

}

}

for (int i=1;i<=5;i++)

printf("%d %d\n",a[i].num,a[i].all);

return 0;

}

查看更多回复
提交回复