为什么错了

P1093 [NOIP2007 普及组] 奖学金

5u0i5n11i @ 2017-10-01 09:16:39

#include<bits/stdc++.h>
using namespace std;
int b[120];
struct student
{
    int y;
    int s;
    int e;
    int z;
};
int main()
{
    student a[120];
    int n,i,l,j;
    cin>>n;
    for (i=1;i<=n;i++)
    {
      cin>>a[i].y>>a[i].s>>a[i].e;b[i]=i;
       a[i].z=a[i].y+a[i].s+a[i].e;}
    for (i=1;i<=n;i++)
       for (j=1;j<=n-i;j++)
        if (a[j+1].z>a[j].z){l=b[j];b[j]=b[j+1];b[j+1]=l;}
        else if (a[j+1].z==a[j].z && a[j+1].y>a[j].y){l=b[j];b[j]=b[j+1];b[j+1]=l;} 
    for (i=1;i<=5;i++)
    cout<<b[i]<<" "<<a[b[i]].z<<endl;
    return 0;
} 

by 5u0i5n11i @ 2017-10-01 14:50:51

已经对了


|