- 奖学金
- 2017-08-09 11:31:08 @
#include<bits/stdc++.h>
using namespace std;
struct student
{
int num,chinese,math,english,total;
}a[110],t;
int main()
{
int n,i,j;
scanf("%d\n",&n);
for(i=1;i<=n;i++)
{
a[i].num=i;
scanf("%d %d %d\n",&a[i].chinese,&a[i].math,&a[i].english);
a[i].total=a[i].chinese+a[i].english+a[i].math;
}
for(i=1;i<n;i++)
{
for(j=1;j<=n-i;j++)
{
if(a[j].total<a[j+1].total)
{t=a[j];a[j]=a[j+1];a[j+1]=t;}
}
}
for(i=1;i<n;i++)
{
if(a[i].total==a[i+1].total&&a[i].chinese<a[i+1].chinese)
{t=a[i];a[i]=a[i+1];a[i+1]=t;}
}
for(i=1;i<n;i++)
{
if(a[i].total==a[i+1].total&&a[i].chinese==a[i+1].chinese&&a[i].num>a[i+1].num)
{t=a[i];a[i]=a[i+1];a[i+1]=t;}
}
for(i=1;i<=5;i++)
cout<<a[i].num<<" "<<a[i].total<<endl;
return 0;
}