zoukankan      html  css  js  c++  java
  • I Love This Game 2115(结构体)

    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
     
    Author
    為傑沉倫
     
    Source
     
     
     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>
    10 #include <algorithm>
    11 #include <iostream>
    12 using namespace std;
    13 struct db
    14 {
    15     char n[100];
    16     char t[100];
    17 };
    18 bool cmp(db a,db b){
    19     if(a.t!=b.t)
    20         return strcmp(a.t,b.t)<0;
    21     else
    22         return strcmp(a.n,b.n)<0;
    23 }
    24 db s[100];
    25 int main()
    26 {
    27     int n,i,j;
    28     int c=0;
    29     int t=1;
    30     while(scanf("%d",&n)&&n)
    31     {
    32         if(t>1)
    33             printf("
    ");
    34         for(i=1;i<=n;i++)
    35             scanf("%s%s",s[i].n,s[i].t);
    36         sort(s+1,s+n+1,cmp);
    37         printf("Case #%d
    ",++c);
    38         for(i=1;i<=n;i++)
    39         {
    40             printf("%s %d
    ",s[i].n,i);
    41             if(strcmp(s[i].t,s[i+1].t)==0)
    42             {
    43                 printf("%s %d
    ",s[i+1].n,i);
    44                 i++;
    45             }
    46         }
    47         t++;
    48     }
    49     return 0;
    50 }
  • 相关阅读:
    [转贴]中国铁塔发布2020年中期财报:营收、利润双增,高效支撑5G规模建设
    struts2总结二:第一个简单的struts2程序
    struts2总结一:MVC设计模式
    解决eclipse报PermGen space内存溢出异常的问题
    java中new关键字和newInstance()方法有什么区别?
    java反射机制
    在easyui中如何修改combobox的下拉框的高度为自适应高度
    百度UEditor从word复制粘贴公式
    百度富文本编辑器从word复制粘贴图片
    HTML编辑器从word复制粘贴图片
  • 原文地址:https://www.cnblogs.com/wangmengmeng/p/4705547.html
Copyright © 2011-2022 走看看