Problem Description
Do you like playing basketball ? If you are , you may know the NBA Skills Challenge . It is the content of the basketball skills . It include several parts , such as passing , shooting , and so on. After completion of the content , the player who takes the shortest time will be the winner . Now give you their names and the time of finishing the competition , your task is to give out the rank of them ; please output their name and the rank, if they have the same time , the rank of them will be the same ,but you should output their names in lexicographic order.You may assume the names of the players are unique.
Is it a very simple problem for you? Please accept it in ten minutes.
Input
This problem contains multiple test cases! Ease test case contain a n(1<=n<=10) shows the number of players,then n lines will be given. Each line will contain the name of player and the time(mm:ss) of their finish.The end of the input will be indicated by an integer value of zero.
Output
The output format is shown as sample below.
Please output the rank of all players, the output format is shown as sample below;
Output a blank line between two cases.
Sample Input
10
Iverson 17:19
Bryant 07:03
Nash 09:33
Wade 07:03
Davies 11:13
Carter 14:28
Jordan 29:34
James 20:48
Parker 24:49
Kidd 26:46
0
Sample Output
Case #1
Bryant 1
Wade 1
Nash 3
Davies 4
Carter 5
Iverson 6
James 7
Parker 8
Kidd 9
Jordan 10
难度不大,但是总是PE,细读了几遍题目,然后改空行,就是PE,最后才看懂题目;
#include <iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
int n;
char str[11][11];
int a[11],b[11],c[11];
// char e=' ';
char d;
int t=0;
while(cin>>n&&n)
{
memset(c,0,sizeof(c));
t++;
if(t>1)
cout<<endl;
cout<<"Case #"<<t<<endl;
for(int i=0; i<n; i++)
{
cin>>str[i]>>a[i]>>d>>b[i];
c[i]=a[i]*60+b[i];
}
for(int i=0; i<n; i++)
{
for(int j=i+1; j<n; j++)
{
if(c[i]>c[j])
{
swap(c[i],c[j]);
swap(str[i],str[j]);
}
if(c[i]==c[j])
{
if(strcmp(str[i],str[j])<0)
continue;
else
swap(str[i],str[j]);
}
}
}
for(int i=0,j=1; i<n; i++)
{
//cout<<a[i]<<" "<<c[i]<<endl;
if(c[i]==c[i-1])
{
cout<<str[i]<<" "<<j-1<<endl;
j+=1;
}
else
{
cout<<str[i]<<" "<<j<<endl;
j++;
}
}
}
return 0;
}