据说“Aborted/IOT trap”是数组越界,但是我始终找不到数组越界的地方。
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
struct Player{
string name,position;
long long credit;
int level,number,status;
};
const string position[5]={"HuFa","ZhangLao","TangZhu","JingYing","BangZhong"};
bool creditcmp(Player A,Player B){
return A.credit>=B.credit;
}
bool statuscmp(Player A,Player B){
if(A.status!=B.status) return A.status<B.status;
else if(A.level!=B.level) return A.level>B.level;
else return A.number<B.number;
}
int main(){
int n,i;
cin>>n;
for(i=0;i<3;i++){
Player highness;
cin>>highness.name>>highness.position>>highness.credit>>highness.level;
cout<<highness.name<<' '<<highness.position<<' '<<highness.level<<endl;
}
if(n>3){
Player others[108];
for(i=0;i<n-3;i++){
cin>>others[i].name>>others[i].position>>others[i].credit>>others[i].level;
others[i].number=i;
}
sort(others,others+n-3,creditcmp);
for(i=0;i<n-3;i++){
if(i<2) others[i].status=0;
else if(i<6) others[i].status=1;
else if(i<13) others[i].status=2;
else if(i<38) others[i].status=3;
else others[i].status=4;
}
for(i=0;i<n-3;i++) others[i].position=position[others[i].status];
sort(others,others+n-3,statuscmp);
for(i=0;i<n-3;i++) cout<<others[i].name<<' '<<others[i].position<<' '<<others[i].level<<endl;
}
return 0;
}