• I love this game201308022009.txt


    I Love This Game
    Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
    Total Submission(s): 4693    Accepted Submission(s): 1613


    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
     

    #include <stdio.h>
    #include <string.h>
    struct stu
    {
     char name[20];
     char sj[10];
    }ren[12];
    int main()
    {
     int l=0,n,k=0,i,j,t;
     char a[12],b[20],c[12];
     while(scanf("%d",&n)&&n!=0)
     {
      for(i=0;i<n;i++)
      {c[i]=i+1;}
      k++;
      for(i=0;i<n;i++)
           scanf("%s%s",ren[i].name,ren[i].sj);
           for(j=1;j<=n-1;j++)
           {
            for(i=0;i<n-j;i++)
            if(strcmp(ren[i].sj,ren[i+1].sj)>=0)
            {strcpy(a,ren[i].sj);
            strcpy(ren[i].sj,ren[i+1].sj);    
            strcpy(ren[i+1].sj,a);
            strcpy(b,ren[i].name);
            strcpy(ren[i].name,ren[i+1].name);
            strcpy(ren[i+1].name,b);}
           }
           for(i=0;i<n;i++)
           {
           if(strcmp(ren[i].sj,ren[i+1].sj)==0)
           {c[i+1]=c[i];
           t=strcmp(ren[i].name,ren[i+1].name);
           if(t>0)
           { strcpy(b,ren[i].name);
            strcpy(ren[i].name,ren[i+1].name);
         strcpy(ren[i+1].name,b);}
           }
           }
           printf(l++?" Case #%d ":"Case #%d ",k);
           //printf(" ");
           //printf(l++?" %s %d ":"%s %d ",ren[0].name,c[0]);
           for(i=0;i<n;i++)
           printf("%s %d ",ren[i].name,c[i]);
           //printf(l++?" %s %d ":"%s %d ",ren[i].name,c[i]);
           //printf(l++?" ":"");
     }
       return 0;

  • 相关阅读:
    助力APP尽情“撒币”!阿里云正式上线移动直播问答解决方案
    Linux API的fork()测试
    完美搞定《DOCKER IN ACTION》第二章示例
    docker+python无头浏览器爬虫
    阿里云播放器SDK的正确打开方式 | Aliplayer Web播放器介绍及功能实现(三)
    11月9日云栖精选夜读:阿里90后工程师_如何用AI程序写出双11打call歌?
    知名网站的 404 页面长啥样?你的404长啥样?
    10月24日云栖精选夜读:2017杭州•云栖大会完美收官 虚拟化平台精彩回顾
    memcache漏洞你补上了吗
    5分钟用Jitpack发布开源库
  • 原文地址:https://www.cnblogs.com/xiaziteng/p/nbamingxing.html
Copyright © 2020-2023  润新知