hdu--2115

Source: Internet
Author: User

I Love this GameTime limit:3000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 6357 Accepted Submission (s): 2175


Problem Descriptiondo You like playing basketball? If you is, 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 takes the shortest time would be the winner. Now give you their names and the time of finishing the competition, your task was to give out the rank of them; Please output their name and the rank, if they has the same time, the rank of them would be is the same, but you should OUTP UT their names in lexicographic order. Assume the names of the players are unique.

Is it a very simple problem for you? Please accept the IT in ten minutes.

Inputthis problem contains multiple test cases! Ease test Case contain a n (1<=n<=10) shows the number of Players,then n lines would be given. Each line would contain the name of the player and the time (MM:SS) of their finish. The end of the input would be indicated by an integer value of zero.

Outputthe output format is shown as sample below.
Please output the rank of any players, the output format is shown as sample below;
Output a blank line between cases.
Sample Input
10Iverson 17:19bryant 07:03nash 09:33wade 07:03davies 11:13carter 14:28jordan 29:34james 20:48parker 24:49Kidd 26:460

Sample Output
Case #1Bryant 1Wade 1Nash 3Davies 4Carter 5Iverson 6James 7Parker 8Kidd 9Jordan 10

Author for Jake
Sourcehdu 2007-10 Programming Contest_warmup
#include <stdio.h> #include <string.h>struct people{char name[50];int time;int rank;} A[11];char temp[50]; int main () {int n,i,count=0,m,s,j;while (scanf ("%d", &n), N) {if (count) printf ("\ n"), count++;p rintf ("Case #%d\n", count); for (i=1;i<=n;i++) {scanf ("%s%d:%d", a[i].name,&m,&s); a[i].time=m*60+s;} for (i=1;i<=n;i++) for (j=i+1;j<=n;j++) {if (a[i].time>a[j].time) {strncpy (temp,a[j].name,50); strncpy (A[j]. name,a[i].name,50); strncpy (a[i].name,temp,50); m=a[i].time;a[i].time=a[j].time;a[j].time=m;}} A[1].rank=1;for (i=2;i<=n;i++) if (a[i].time==a[i-1].time) A[i].rank=a[i-1].rank;else a[i].rank=i;for (i=1;i<= n;i++) printf ("%s%d\n", A[i].name,a[i].rank);} return 0;}


hdu--2115

Related Keywords:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.