Entity303 @ 2018-10-30 19:16:36
#include<bits/stdc++.h>
using namespace std;
int n;
struct t
{
int number;
int math;
int chinese;
int english;
int score;
}a[302];
int main()
{
freopen(".in","r",stdin);
freopen(".out","w",stdout);
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i].chinese>>a[i].math>>a[i].english;
a[i].score=a[i].chinese+a[i].math+a[i].english;
a[i].number=i;
}
for(int i=n-1;i>=1;i--)
{
for(int j=1;j<=i;j++)
{
if(a[j].score<a[j+1].score)
{
swap(a[j],a[j+1]);
}
else if(a[j].score==a[j+1].score)
{
if(a[j].chinese<a[j+1].chinese)
{
swap(a[j],a[j+1]);
}
else if(a[j].chinese==a[j+1].chinese)
{
if(a[j].number>a[j+1].number)
{
swap(a[j],a[j+1]);
}
}
}
}
}
for(int i=1;i<=5;i++)
{
cout<<a[i].number<<" "<<a[i].score<<endl;
}
return 0;
}
by Entity303 @ 2018-10-30 19:46:27
真的神奇,我之前一道题目打了freopen交上去0分,这里却是10分
by WuShangxuan @ 2018-11-02 19:41:41
打freopen竟然有分???颠覆了本蒟蒻的价值观