HDU,2215,I Love This Game
来源:互联网 发布:淘宝如何编辑宝贝分类 编辑:程序博客网 时间:2024/06/11 08:21
I Love This Game
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4692 Accepted Submission(s): 1612
Is it a very simple problem for you? Please accept it in ten minutes.
Please output the rank of all players, the output format is shown as sample below;
Output a blank line between two cases.
10Iverson 17:19Bryant 07:03Nash 09:33Wade 07:03Davies 11:13Carter 14:28Jordan 29:34James 20:48Parker 24:49Kidd 26:460
Case #1Bryant 1Wade 1Nash 3Davies 4Carter 5Iverson 6James 7Parker 8Kidd 9Jordan 10#include <stdio.h>
#include <string.h>
struct player
{
char name[20];
int time;
};
int main()
{
struct player a[15];
int n,i,j,k,temp,times;
char tstr[20];
times=0;
if (scanf("%d",&n),n==0) return 0;
do
{
for (i=1;i<=n;i++)
{
scanf("%s%d:%d",&a[i].name,&a[i].time,&k);
a[i].time=a[i].time*60+k;
}
for (i=1;i<=n-1;i++)
for (j=i+1;j<=n;j++)
if (a[i].time>a[j].time||(a[i].time==a[j].time && strcmp(a[i].name,a[j].name)>0))
{
temp=a[i].time;
a[i].time=a[j].time;
a[j].time=temp;
strcpy(tstr,a[i].name);
strcpy(a[i].name,a[j].name);
strcpy(a[j].name,tstr);
}
printf("Case #%d\n",++times);
k=1;
for (i=1;i<=n;i++)
{
if (a[i].time!=a[i-1].time)
k=i;
printf("%s %d\n",a[i].name,k);
}
if (scanf("%d",&n),n)
puts("");
else return 0;
}while (1);
return 0;
}
因为这道题在排序交换时需要在原来的条件a[i].time>a[j].time 之外附加一个条件(a[i].time==a[j].time && strcmp(a[i].name,a[j].name)>0)在输出时使用if (a[i].time!=a[i-1].time) k=i;的语句完成
- HDU,2215,I Love This Game
- hdu 2115 I Love This Game
- HDU 2115 I Love This Game
- HDU 2115 I Love This Game
- hdu 2115 I Love This Game
- hdu 2115 I Love This Game
- I Love This Game hdu 2115
- HDU 2115 I Love This Game
- hdu 2115 I Love This Game
- HDU--2115 I Love This Game
- hdu 2115 I Love This Game
- hdu-2115-I Love This Game
- hdu 2115 I Love This Game
- HDU 2115 I Love This Game
- I Love This Game!
- I Love This Game
- I Love This Game
- pku1678 I Love this Game!
- quagga线程机制
- 循环链表的构建
- 面试总结
- LOCAL_WHOLE_STATIC_LIBRARIES与LOCAL_STATIC_LIBRARIES的区别
- Legacy __sync Built-in Functions for Atomic Memory Access
- HDU,2215,I Love This Game
- UNIX网络编程——epoll 系列函数简介、与select、poll 的区别
- 【整理】Python中,如何将反斜杠u类型(\uXXXX)的字符串,转换为对应的unicode的字符
- HTTP协议详解
- 2012华为机试题目(C/C++)
- 动态menu导航条以及treeview树
- 【Android游戏开发十一】手把手让你爱上Android sdk自带“9妹”(9patch 工具),让Android游戏开发更方便!
- Linux NFS 说明,配置及故障分析
- 基于MDK的分散加载文件