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 <math.h>
#include <queue>
#include <vector>
#include <stack>
#include <map>
#include <string>
#include <string.h>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
struct db
{
char n[];
char t[];
};
bool cmp(db a,db b){
if(a.t!=b.t)
return strcmp(a.t,b.t)<;
else
return strcmp(a.n,b.n)<;
}
db s[];
int main()
{
int n,i,j;
int c=;
int t=;
while(scanf("%d",&n)&&n)
{
if(t>)
printf("\n");
for(i=;i<=n;i++)
scanf("%s%s",s[i].n,s[i].t);
sort(s+,s+n+,cmp);
printf("Case #%d\n",++c);
for(i=;i<=n;i++)
{
printf("%s %d\n",s[i].n,i);
if(strcmp(s[i].t,s[i+].t)==)
{
printf("%s %d\n",s[i+].n,i);
i++;
}
}
t++;
}
return ;
}

I Love This Game 2115(结构体)的更多相关文章

  1. Go结构体实现类似成员函数机制

    Go语言结构体成员能否是函数,从而实现类似类的成员函数的机制呢?答案是肯定的. package main import "fmt" type stru struct { testf ...

  2. C#基础回顾(二)—页面值传递、重载与重写、类与结构体、装箱与拆箱

    一.前言 -孤独的路上有梦想作伴,乘风破浪- 二.页面值传递 (1)C#各页面之间可以进行数据的交换和传递,页面之间可根据获取的数据,进行各自的操作(跳转.计算等操作).为了实现多种方式的数据传递,C ...

  3. go语言结构体

    定义: 是一种聚合的数据类型,是由零个或多个任意类型的值聚合成的实体. 成员: 每个值称为结构体的成员. 示例: 用结构体的经典案例处理公司的员工信息,每个员工信息包含一个唯一的员工编号.员工的名字. ...

  4. C语言中的结构体

    用户自己建立自己的结构体类型 1.  定义和使用结构体变量 (1).结构体的定义 C语言允许用户自己建立由不同类型数据组成的组合型的数据结构,它称为结构体. (2).声明一个结构体类型的一般形式为: ...

  5. C++_系列自学课程_第_12_课_结构体

    #include <iostream> #include <string> using namespace std; struct CDAccount { double bal ...

  6. java socket传送一个结构体给用C++编写的服务器解析的问题

    另一端是Java写客户端程序,两者之间需要通信.c++/c接收和发送的都是结构体,而Java是直接发送的字节流或者byte 数组.解决方法:c++/c socket 在发送结构体的时候其实发送的也是字 ...

  7. swift学习笔记3——类、结构体、枚举

    之前学习swift时的个人笔记,根据github:the-swift-programming-language-in-chinese学习.总结,将重要的内容提取,加以理解后整理为学习笔记,方便以后查询 ...

  8. HDOJ 1009. Fat Mouse' Trade 贪心 结构体排序

    FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  9. C语言结构体对齐

    1.结构体变量中的元素如何访问? (1)数组中元素的访问方式:表面上有2种方式(数组下标方式和指针方式):实质上都是指针方式访问.(2)结构体变量中的元素访问方式:只有一种,用.或者->的方式来 ...

  10. C与指针(结构体指针,函数指针,数组指针,指针数组)定义与使用

    类型 普通指针 指针数组(非指针类型) 数组指针 结构体指针 函数指针 二重指针 定义方式 int *p; int *p[5]; int (*p)[5]; int a[3][5]; struct{.. ...

随机推荐

  1. 图表引擎AChartEngine 二

    这几天项目涉及到android图表绘制,网上找的Demo都是大同小异,也就如上篇博文所写的一样是基本函数的实现.可是所有能找到的Demo都和设计图不符.木有办法,Leader发话啦,万不得已的情况下不 ...

  2. iphone内容开发技术学习

    一.iOS基础 1 开发环境搭建以及IOS组件.框架的概要介绍. 2 mac操作系统与iOS操作系统 3 xcode IDE开发环境的初始 二.C语言基础 1数据类型.表达式与控制流程语句 2数组.函 ...

  3. JavaScript IDE

    哪些JavaScript IDE最好用?   阅读本文之前,分享大家一张图片,看图会发现JavaScript开发需求最高,占比达到42.84%,因此掌握JavaScript语言好工作就不愁啦,工欲善其 ...

  4. RH033读书笔记(15)-Lab 16 The Linux Filesystem

    Lab 16 The Linux Filesystem Goal: Develop a better understanding of Linux filesystem essentials incl ...

  5. VS2015在对GIT的支持

    VS2015在对GIT的支持 相比VS2013,VS2015在对GIT的支持上有了更强大的支持.本篇仅作抛砖引玉,不做过多介绍: 1. 打开VS 2015起始页 2. 打开团队资源管理器 打开[本地G ...

  6. int a[5]={1,2,3,4,5};printf(&quot;%d\n&quot;, *((int*)(&amp;a+1)-2);

    有说服力的笔试题有一定的期限,问:什么是结果,答案是4,为什么要挤? 我明白(不知道是不正确): &a这是一个数组指针,类型int[5],然后&a添加1其实a+sizeof(int)* ...

  7. js的StringBuffer实施和使用类

    <strong>JAVA有一个StringBuffer分类,js但不是在下面,以实现自己的简单js的StringBuffer分类.</strong> //创建一个StringB ...

  8. MemCache分布式内存对象缓存系统

    MemCache超详细解读 MemCache是一个自由.源码开放.高性能.分布式的分布式内存对象缓存系统,用于动态Web应用以减轻数据库的负载.它通过在内存中缓存数据和对象来减少读取数据库的次数,从而 ...

  9. 复制(5)——事务复制中的发布者(Publisher)

    发布者是所有被复制(replicated)的数据的集合.每个发布者可以有多个发布(publication),每个发布项包含多个项目(articles),但是这些发布必须处于一个单一的数据库中,而每个项 ...

  10. [原] Jenkins Android 自动打包配置(转)

    一.Jenkins自动打包配置 目标:1. 自动打包:2. 自动上传:3. 友好下载 1. Jenkins简介 Jenkins是基于Java开发的一种持续集成工具,用于监控持续重复的工作. 减少重复劳 ...