• 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 }
    功不成,身已退
  • 相关阅读:
    Miracast
    linux软中断与硬中断实现原理概述
    入门视频采集与处理(BT656简介)
    emms指令在MMX指令中的作用
    linux进程的地址空间,核心栈,用户栈,内核线程
    linux 线程的内核栈是独立的还是共享父进程的?
    进程内核栈、用户栈及 Linux 进程栈和线程栈的区别
    Gson JsonParser的使用
    封装JDBC事务操作,执行存储过程测试
    Oracle 存储过程,临时表,动态SQL测试
  • 原文地址:https://www.cnblogs.com/dongsheng/p/2611895.html
Copyright © 2020-2023  润新知