帮忙看看哪里错了

P1093 [NOIP2007 普及组] 奖学金

Grussg @ 2018-11-01 20:58:31

include<bits/stdc++.h>

using namespace std; int main(){ int a[305],b[305],c[305],i,g,j,n,e; cin>>n;

for(i=1;i<=n;i++)
{
    cin>>e>>j>>g;
    a[i]=i;
    b[i]=e+g+j;
    c[i]=e;
}
for(j=1;j<=n-1;j++)
{
     for(i=1;i<=n;i++)
{
    if(b[i]<b[i+1])
    {   
    swap(a[i],a[i+1]);
    swap(b[i],b[i+1]);
    swap(c[i],c[i+1]);
    }
    else if(b[i]==b[i+1])
    {
        if(c[i]<c[i+1])
        {
        swap(a[i],a[i+1]);
        swap(b[i],b[i+1]);
        swap(c[i],c[i+1]);
        }
        else if(c[i]==c[i+1])
        {
            if(a[i]<a[i+1])
            {
            swap(a[i],a[i+1]);
            swap(b[i],b[i+1]);
            swap(c[i],c[i+1]);
            }
        }
    }
}
}
for(i=1;i<=5;i++)
{
    cout<<a[i]<<" "<<b[i]<<endl;
}
return 0;

}


|