求助:排序问题
#include<iostream>using namespace std;
void main()
{int i=0,n=0,j=0;
cout<<"please input the number of the players"<<endl;
cin>>n;
int a[100]={0},b[100]={0},c[100]={0},t1(0),t2(0),t3(0),r[100]={0};
for (i=0;i<n;i++)
{cout<<"the "<<i+1<<" player score(3 items):";
cin>>a[i]>>b[i]>>c[i];}
cout<<"the rank is:"<<endl;
for(j=0;j<n;j++)
{
for(i=0;i<n;i++)
{
if(a[i]!=t1)
{if(a[i]>t1)
{t1=a[i];
r[j]=i+1;
}
}
else
if(b[i]!=t2)
{if(b[i]>t2)
{t2=b[i];
r[j]=i+1;
}
}
else
if(c[i]!=t3)
{if(c[i]>t3)
{t3=c[i];
r[j]=i+1;
}
}
}
t1=t2=t3=0;
cout<<"the "<<r[j]<<" player: "<<a[r[j]-1]<<" "<<b[r[j]-1]<<" "<<c[r[j]-1]<<" "<<endl;
for(i=r[j]-1;i<n;i++)
a[i]=a[i+1];
b[i]=b[i+1];
c[i]=c[i+1];
}
}
此程序运行不正确,后面数字的排序正常,但是序号会出错,不知道为什么。菜鸟求助。。