I Love this Game 2115 (struct)

Source: Internet
Author: User
Tags strcmp

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 Input10iverson 17:19bryant 07:03nash 09:33wade 07:03davies 11:13carter 14:28jordan 29:34James 20:48Parker 24:49kidd 26:460

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

Author for Jake

Sourcehdu 2007-10 Programming Contest_warmup
1#include <stdio.h>2#include <math.h>3#include <queue>4#include <vector>5#include <stack>6#include <map>7#include <string>8#include <string.h>9#include <cstring>Ten#include <algorithm> One#include <iostream> A using namespacestd; - structDB - { the     Charn[ -]; -     Chart[ -]; - }; - BOOLCMP (db a,db b) { +     if(a.t!=b.t) -         returnstrcmp (A.T,B.T) <0; +     Else A         returnstrcmp (A.N,B.N) <0; at } -DB s[ -]; - intMain () - { -     intn,i,j; -     intC=0; in     intt=1; -      while(SCANF ("%d", &n) &&N) to     { +         if(t>1) -printf"\ n"); the          for(i=1; i<=n;i++) *scanf"%s%s", s[i].n,s[i].t); $Sort (s+1, s+n+1, CMP);Panax Notoginsengprintf"Case #%d\n",++c); -          for(i=1; i<=n;i++) the         { +printf"%s%d\n", s[i].n,i); A             if(strcmp (s[i].t,s[i+1].t) = =0) the             { +printf"%s%d\n", s[i+1].n,i); -i++; $             } $         } -t++; -     } the     return 0; -}

I Love this Game 2115 (struct)

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.