I Love This Game

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 6357    Accepted Submission(s): 2175

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

#include<stdio.h>
#include<string.h>
struct people{
char name[50];
int time;
int rank;
} a[11];
char temp[50];
int main()
{
int n,i,count=0,m,s,j;
while(scanf("%d",&n),n)
{
if(count) printf("\n");
count++;
printf("Case #%d\n",count);
for(i=1;i<=n;i++)
{
scanf("%s %d:%d",a[i].name,&m,&s);
a[i].time=m*60+s;
}
for(i=1;i<=n;i++)
for(j=i+1;j<=n;j++)
{
if(a[i].time>a[j].time)
{
strncpy(temp,a[j].name,50);
strncpy(a[j].name,a[i].name,50);
strncpy(a[i].name,temp,50);
m=a[i].time;
a[i].time=a[j].time;
a[j].time=m;
}
}
a[1].rank=1;
for(i=2;i<=n;i++)
if(a[i].time==a[i-1].time)
a[i].rank=a[i-1].rank;
else
a[i].rank=i;
for(i=1;i<=n;i++)
printf("%s %d\n",a[i].name,a[i].rank);
}
return 0;
}

HDU--2115的更多相关文章

  1. HDU 2115 I Love This Game

    http://acm.hdu.edu.cn/showproblem.php?pid=2115 Problem Description Do you like playing basketball ? ...

  2. HDOJ(HDU) 2115 I Love This Game(排序排序、、、)

    Problem Description Do you like playing basketball ? If you are , you may know the NBA Skills Challe ...

  3. -【线性基】【BZOJ 2460】【BZOJ 2115】【HDU 3949】

    [把三道我做过的线性基题目放在一起总结一下,代码都挺简单,主要就是贪心思想和异或的高斯消元] [然后把网上的讲解归纳一下] 1.线性基: 若干数的线性基是一组数a1,a2,a3...an,其中ax的最 ...

  4. HDU——PKU题目分类

    HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 ...

  5. [转] HDU 题目分类

    转载来自:http://www.cppblog.com/acronix/archive/2010/09/24/127536.aspx 分类一: 基础题:1000.1001.1004.1005.1008 ...

  6. HDU ACM 题目分类

    模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 104 ...

  7. HDU 5643 King's Game 打表

    King's Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5643 Description In order to remember hi ...

  8. 转载:hdu 题目分类 (侵删)

    转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012. ...

  9. hdu 2117:Just a Numble(水题,模拟除法运算)

    Just a Numble Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tot ...

  10. HDU——2119 Matrix

    Matrix Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Sub ...

随机推荐

  1. Who's in the Middle

    FJ is surveying his herd to find the most average cow. He wants to know how much milk this 'median' ...

  2. python:发送消息给微信企业号

    # -*- coding:utf-8 -*- import requests import json ''' 基础环境:微信企业号 version:python 2.7 ''' class Send_ ...

  3. lodash源码分析之NaN不是NaN

    暗恋之纯粹,在于不求结果,完全把自己锁闭在一个单向的关系里面. --梁文道<暗恋到偷窥> 本文为读 lodash 源码的第五篇,后续文章会更新到这个仓库中,欢迎 star:pocket-l ...

  4. 高度-宽度关系,同一div、不同div高度与宽度关系控制函数

    //对象1的高度等于对象2的高度n倍,调用方法:Ht1DivideHt2('#div2','#div1',3)//div2的高度是div1高度的3倍function Ht1DivideHt2(obj1 ...

  5. COMPUTE子句和Group By

                        首先声明一下,这个COMPUTE语法在SQLServer 2012之后,就废弃使用了,详情请看https://msdn.microsoft.com/librar ...

  6. 深入C#.NET数据类型

    深入C#数据类型 --不同类型的参数传递使用值传递,在方法中对参数的更改在调用后不能保留.使用ref方式传递,可以保留对参数值的更改. ---值方式参数传递和引用方式传递使用值方式(不用ref修饰)传 ...

  7. Head First设计模式之生成器模式

    一.定义 将一个复杂对象的构建与它的表示分离,使得同样的构建过程可以创建不同的表示.建造者模式是一种对象创建型模式. 二.结构 角色 Builder(抽象建造者):它为创建一个产品Product对象的 ...

  8. robotframework的学习笔记(十六)----robotframework标准库String

    官方文档:http://robotframework.org/robotframework/latest/libraries/String.html Introduction A test libra ...

  9. CSS3 美女动画相框

    把下面的内容放到一个body内,运行看一看:) <style> *{ margin:0; padding:0;} .bg1{ background-image:-moz-linear-gr ...

  10. 第九章:Python の 网络编程基础(一)

    本課主題 何为TCP/IP协议 初认识什么是网络编程 网络编程中的 "粘包" 自定义 MySocket 类 本周作业 何为TCP/IP 协议 TCP/IP协议是主机接入互网以及接入 ...