zoukankan      html  css  js  c++  java
  • HDOJ2115 I Love This Game 排序问题

    I Love This Game

    Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
    Total Submission(s): 3528    Accepted Submission(s): 1211


    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
     1 /* 功能Function Description:     HDOJ-2115  排序问题
     2    开发环境Environment:          DEV C++ 4.9.9.1
     3    技术特点Technique:
     4    版本Version:
     5    作者Author:                   可笑痴狂
     6    日期Date:                     20120728
     7    备注Notes:
     8 */
     9 
    10 #include<stdio.h>
    11 #include<string.h>
    12 #include<stdlib.h>
    13 
    14 struct team
    15 {
    16     char name[100];
    17     char time[10];
    18 }a[15];
    19 
    20 int comp(const void *p1,const void *p2)
    21 {
    22     struct team *q1=(struct team *)p1;
    23     struct team *q2=(struct team *)p2;
    24     if(strcmp(q1->time,q2->time))
    25         return strcmp(q1->time,q2->time);
    26     else
    27         return strcmp(q1->name,q2->name);
    28 }
    29 
    30 int main()
    31 {
    32     int n,i,T,rank;
    33     T=0;
    34     while(scanf("%d",&n),n)
    35     {
    36         rank=1;
    37         for(i=0;i<n;++i)
    38             scanf("%s%s",a[i].name,a[i].time);
    39         qsort(a,n,sizeof(struct team),comp);
    40         if(T)
    41             printf("\n");
    42         printf("Case #%d\n",++T);
    43         for(i=0;i<n;++i)
    44         {
    45             if(i==0||i&&strcmp(a[i].time,a[i-1].time))
    46             {
    47                 rank=i+1;
    48                 printf("%s %d\n",a[i].name,rank);
    49             }
    50             else
    51                 printf("%s %d\n",a[i].name,rank);
    52         }
    53     }
    54     return 0;
    55 }
    功不成,身已退
  • 相关阅读:
    Tp控制器
    thinkphp总体设计
    视频会议管理系统操作步骤(新)
    视频会议(旧)
    HCIE实验LAB_1(1)
    HCIE实验LAB_1(2)
    HCIE实验LAB_1(3)
    HCIE实验LAB_1(4)
    HCIE实验LAB_1(5)
    HCIE实验LAB_1(6)
  • 原文地址:https://www.cnblogs.com/dongsheng/p/2611895.html
Copyright © 2011-2022 走看看