zoukankan      html  css  js  c++  java
  • HDUOJ2115I Love This Game

    I Love This Game

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


    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
     
     
     
    View Code
    #include<stdio.h>
    #include<string.h>
    struct
    {
          char name[30];
          char time[8];
          int mc;
    }data[11];
    int main()
    {
      int n,i,k=1,j;
      int flag;
      char ttime[8],tname[30];
      while(scanf("%d",&n)&&n)
      {
         for(i=0;i<n;i++)
            scanf("%s %s",&data[i].name,&data[i].time);
            for(i=0;i<n;i++)
             for(j=0;j<n;j++)
               if(strcmp(data[i].time,data[j].time)<0)
                   {
                     /*strcpy(s[0],data[i]);
                     strcpy(data[i],data[j]);
                     strcpy(data[j],s[0]);*/
                     strcpy(tname,data[i].name);
                     strcpy(data[i].name,data[j].name);
                     strcpy(data[j].name,tname);
                     strcpy(ttime,data[i].time);
                     strcpy(data[i].time,data[j].time);
                     strcpy(data[j].time,ttime);
                     
                   }
                   if(k>1)printf("\n");
                   printf("Case #%d\n",k++);
            // printf("%s %d\n",data[0].name,1);
            for(i=0;i<n;i++)
             data[i].mc=i+1;
             for(i=0;i<n;i++)
               if(strcmp(data[i].time,data[i+1].time)==0)
                 data[i+1].mc=data[i].mc;
          for(i=0;i<n;i++)
          printf("%s %d\n",data[i].name,data[i].mc);
              
      }
      return 0;
    }
  • 相关阅读:
    继承关系中子类使用@Data注解问题
    Professional, Entreprise, Architect版本的区别
    Delphi中ARC内存管理的方向
    技术的止境(客户价值第一,快速实现第二,边做边学,迅速成为牛人。紧贴客户的需求去做技术,立于不败之地。追求的目标:把一项产品去做好,用产品去养活自己和家人)good
    C++ 函数模板与类模板(使用 Qt 开发编译环境)
    C++进阶之虚函数表
    Net反编译软件
    python虚拟环境--virtualenv和virtualenvwrapper
    Windows同时安装python3和python2
    python的pip源在windows和linux修改
  • 原文地址:https://www.cnblogs.com/zhaojiedi1992/p/zhaojiedi_2012_07_270000.html
Copyright © 2011-2022 走看看