HDU2115-I Love This Game
来源:互联网 发布:3d建模编程 编辑:程序博客网 时间:2024/06/10 05:02
题意:
对于给出的人按时间排序。时间相同按人名从小到大排序。
思路:
把时间人名都做成字符串。
#include <iostream>#include <stdio.h>#include <cstring>#include <string.h>#include <algorithm>using namespace std;struct node{ string name; string time;}a[105];int cmp(node x,node y){ if(x.time!=y.time) return x.time<y.time; else return x.name<y.name;}int main(){ int n; int cnt=1; while(cin>>n,n) { string s ; if(cnt!=1) cout<<endl; for(int i=1;i<=n;i++) { cin>>a[i].name; cin>>a[i].time; } sort(a+1,a+1+n,cmp); printf("Case #%d\n",cnt++); int acc=0; for(int i=1;i<=n;i++) { if(a[i].time!=a[i-1].time ) { acc=0; cout<<a[i].name<<" "<<i-acc; } else { acc++; cout<<a[i].name<<" "<<i-acc; } cout<<endl; } }}
0 0
- HDU2115-I Love This Game
- HDU2115:I Love This Game
- HDU2115 I Love This Game
- HDU2115 I LOVE THIS GAME
- HDU2115-I Love This Game
- hdu2115 I Love This Game(排名)
- I Love This Game!
- I Love This Game
- I Love This Game
- pku1678 I Love this Game!
- poj1678 I Love this Game!
- POJ1678 I Love this Game!
- poj1678 I Love this Game!
- C - I Love This Game
- 比赛 I Love This Game
- I Love This Game 2115
- HDOJ2115 I Love This Game
- hdu 2115 I Love This Game
- C语言 - 自定义大小写字符转换函数的实现
- RichTextBox复制一段带格式的Excel的文本内容,粘贴后一定长度后没有\t(制表符)的处理方式
- JAVA利用第三方平台发送短信验证码
- 知识点四:JQuery--操作class ==addClass(),removeClass(), toggleClass(),css()
- Android 中查看logcat的另一种方式
- HDU2115-I Love This Game
- POJ 2049Tautology(模拟)
- Choreographer 丢帧计算
- java web中 /代表的目录
- request的getParameter() 和getAttribute()方法的区别
- perl 判断不包含某字符串
- 我的2016---悲喜交加的一年
- tmux配置小谈
- 创建github博客