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 }
  • 相关阅读:
    [SDOI 2009] HH去散步
    [SDOI 2017] 新生舞会
    【期望 数学】7.6神经衰弱
    初涉2-SAT
    【tarjan 拓扑排序 dp】bzoj1093: [ZJOI2007]最大半连通子图
    【贪心】bzoj1572: [Usaco2009 Open]工作安排Job
    【贪心优化dp决策】bzoj1571: [Usaco2009 Open]滑雪课Ski
    概述「并查集补集转化」模型&&luoguP1330 封锁阳光大学
    初涉tarjan缩点
    初涉三元环
  • 原文地址:https://www.cnblogs.com/wangmengmeng/p/4705547.html
Copyright © 2011-2022 走看看