杭电1006为什么不能AC
#include <iostream>#include <cstring>
#include <cstdlib>
#include <functional>
#include <algorithm>
#include <string>
using namespace std;
typedef struct
{
string name;
string time;
}ch;
int cmp(const void * a ,const void * b);
int main()
{
int n;
ch play[100];
int k=1;
while(scanf("%d",&n)&&n)
{
int i=0;
for(i=0;i<n;i++)
cin>>play[i].name>>play[i].time;
qsort(play,n,sizeof(ch),cmp);
cout<<endl<<"Case #"<<k<<endl;
int j=1;
for(i=0;i<n;i++)
{
if(play[i].time==play[i+1].time)
{
cout<<play[i].name<<' '<<j<<endl;
cout<<play[i+1].name<<' '<<j<<endl;
i++;
j=j+2;
}
else
{
cout<<play[i].name<<' '<<j<<endl;
j++;
}
}
cout<<endl;
k++;
}
system("pause");
return 0;
}
int cmp(const void * a ,const void * b)
{
ch * c=(ch *)a;
ch * d=(ch *)b;
if(c->time!=d->time)
return (*(ch *)c).time<(*(ch *)d).time?-1:1;
else
{
return (*(ch *)c).name<(*(ch *)b).name?-1:1;
}
}