hdu-2115(结构体,sort) I Love This Game
来源:互联网 发布:ubuntu mentohust下载 编辑:程序博客网 时间:2024/05/17 12:48
I Love This Game
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 6387 Accepted Submission(s): 2187
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.
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.
Please output the rank of all players, the output format is shown as sample below;
Output a blank line between two cases.
Sample Input
10Iverson 17:19Bryant 07:03Nash 09:33Wade 07:03Davies 11:13Carter 14:28Jordan 29:34James 20:48Parker 24:49Kidd 26:460
Sample Output
Case #1Bryant 1Wade 1Nash 3Davies 4Carter 5Iverson 6James 7Parker 8Kidd 9Jordan 10
# include<stdio.h># include<string.h># include<algorithm>using namespace std;struct bb{char a[15];char b[15];}c[10];int cmp1(bb x,bb y){return strcmp(x.b,y.b)<0;}int cmp2(bb x,bb y){if(strcmp(x.b,y.b)==0) return strcmp(x.a,y.a)<0;else return strcmp(x.b,y.b)<0;}int main(){ int m,k=0; int q=1; while(scanf("%d",&m)&&m) { if(q>1) printf("\n");//大坑 栽在格式上已经数不清了。。。 int i,t; for(i=0;i<m;i++) scanf("%s %s",c[i].a ,c[i].b); int *z=(int*)malloc(sizeof(int)*m); memset(z,0,sizeof(z)); sort(c,c+m,cmp1); sort(c,c+m,cmp2); k++; printf("Case #%d\n",k); for(i=0,t=1;i<m;i++) {z[i]=t; if(strcmp(c[i].b ,c[i+1].b )!=0)t=i+2; } for(i=0;i<m;i++) printf("%s %d\n",c[i].a,z[i]); q++; }}水题,格式略坑
0 0
- hdu-2115(结构体,sort) I Love This Game
- hdu 2115 I Love This Game 典型的结构体排序
- HDU 2115 I Love This Game(结构体排序 or pair)
- 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 2115
- HDOJ(HDU) 2115 I Love This Game(排序排序、、、)
- Dynamics CRM 依赖组件类型为应用程序功能区导致的无法删除实体问题的解决方法
- SVN Error resolving case of xxxx
- String与InputStream相互转换
- Android 拍照或从相册取图片并裁剪
- avi视频格式转yuv格式与播放yuv视频
- hdu-2115(结构体,sort) I Love This Game
- oracle 11gR2 本地能连接上,远程连接不上,错误码:ORA-12541 TNS 无监听程序
- Android 监听器
- Core Animaiton - 5
- hdu 5305 Friends
- 数据结构学习--创建链表
- HTML空格
- 微信公众平台开发时需要判断微信浏览器访问
- 2015.7.23 简陋的学生通讯录管理系统