非常感謝指導
已可run 但出現 第25個測資錯誤
#include <iostream>
#include <cstdlib>
using namespace std;
struct world
{
string name; // 隊名
int score; // 排名時數
} ;
typedef struct world snd; // 定義資料型態名稱--排名
bool cmp(snd a,snd b){
if(a.score<b.score ) return 1;
return 0;/*0表示要交換*/
}
int main(void){
int n=0;
while( cin >> n ){
if ( n==0 ) { break; }
snd s[n];
string tot;
int hh=0,mm=0,ss=0,ms=0;
for(int i=0;i<n;i++){
cin >>s[i].name>>tot;
hh= atoi(tot.substr(0,2).c_str())*3600000 ;
mm= atoi(tot.substr(3,2).c_str())*60000 ;
ss= atoi(tot.substr(6,2).c_str())*1000 ;
s[i].score=hh+mm+ss;
if ( tot.length()>10 ) {
s[i].score+= atoi(tot.substr(9,tot.length()-9).c_str());
}
}
sort(s,s+n,cmp); //排序
cout<<"LIST START"<<endl;
int k=0;
k=n/3;
for(int i=0;i<k;i++){
cout <<s[i].name<<endl;
}
for(int i=k;i<n;i++){
if ( s[k-1].score == s[i].score ) {
cout <<s[i].name<<endl;
}
}
cout<<"LIST END"<<endl;
}
//system("pause");
return 0;
}