best code #54 div 2 A 水
A problem of sorting
There are many people's name and birth in a list.Your task is to print the name from young to old.(There is no pair of two has the same age.)
First line contains a single integer T≤100T \leq 100T≤100 which denotes the number of test cases.
For each test case, there is an positive integer n(1≤n≤100)n (1 \leq n \leq 100)n(1≤n≤100) which denotes the number of people,and next nnn lines,each line has a name and a birth's year(1900-2015) separated by one space.
The length of name is positive and not larger than 100100100.Notice name only contain letter(s),digit(s) and space(s).
For each case, output nnn lines.
2
1
FancyCoder 1996
2
FancyCoder 1996
xyz111 1997
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<map>
#include<queue>
using namespace std;
struct node
{
char name[105];
int birthday;
friend bool operator <(node a,node b)
{
return a.birthday<b.birthday;
}
};
node q1,q2;
priority_queue<node>q;
int main()
{
int t,n;
while(scanf("%d",&t)!=EOF)
{
for(int i=1; i<=t; i++)
{
scanf("%d",&n);
getchar();
for(int j=1; j<=n; j++)
{
char str[105],strr[105];
int birth;
memset(strr,0,sizeof(strr));
memset(str,0,sizeof(str));
cin.getline(str,105);
int len=strlen(str);
birth=str[len-1]-'0'+(str[len-2]-'0')*10+(str[len-3]-'0')*100+(str[len-4]-'0')*1000;
for(int k=0; k<=len-1-5; k++)
{
strr[k]=str[k]; }
strcpy(q1.name,strr);
q1.birthday=birth;
q.push(q1);
}
while(!q.empty())
{
q2=q.top();
q.pop();
cout<<q2.name<<endl;
}
}
}
return 0;
}
best code #54 div 2 A 水的更多相关文章
- Codeforces Beta Round #54 (Div. 2)
		Codeforces Beta Round #54 (Div. 2) http://codeforces.com/contest/58 A 找子序列 #include<bits/stdc++.h ... 
- Codeforces Round #365 (Div. 2) A 水
		A. Mishka and Game time limit per test 1 second memory limit per test 256 megabytes input standard i ... 
- Codeforces Round #303 (Div. 2) B 水 贪心
		B. Equidistant String time limit per test 1 second memory limit per test 256 megabytes input standar ... 
- Codeforces Round #303 (Div. 2)  A 水
		A. Toy Cars time limit per test 1 second memory limit per test 256 megabytes input standard input ou ... 
- Codeforces Round #394 (Div. 2)A水 B暴力 C暴力  D二分 E dfs
		A. Dasha and Stairs time limit per test 2 seconds memory limit per test 256 megabytes input standard ... 
- Codeforces Round #169 (Div. 2) A水  B   C区间更新  D 思路
		A. Lunch Rush time limit per test 2 seconds memory limit per test 256 megabytes input standard input ... 
- Codeforces Round #337 (Div. 2) A水
		A. Pasha and Stick time limit per test 1 second memory limit per test 256 megabytes input standard i ... 
- Codeforces Round #364 (Div. 2) A 水
		A. Cards time limit per test 1 second memory limit per test 256 megabytes input standard input outpu ... 
- Codeforces Round #316 (Div. 2) A  水
		A. Elections time limit per test 1 second memory limit per test 256 megabytes input standard input o ... 
随机推荐
- 1.1.0 Unity零基础入门2——Roll a Ball
			1. 游戏界面 2.代码 //FoodRotate - - 控制cube旋转 using System.Collections; using System.Collections.Generic; u ... 
- Struts2(九.利用layer组件实现图片显示功能)
			1.layer前端组件介绍 layer是一款口碑极佳的web弹层组件,她具备全方位的解决方案,致力于服务各个水平段的开发人员,您的页面会轻松地拥有丰富而友好的操作体验. http://sentsin. ... 
- Halcon介绍和下载安装视频教程
			------------------------Halcon,Visionpro高清视频教程,点击下载视频-------------------------- 
- SIG蓝牙mesh笔记5_Provisionging
			目录 Bluetooth Mesh Provisioning Provisioning bearer layer Generic Provisioning PDU Bluetooth Mesh Pro ... 
- 基于Kubernetes(k8s)网络方案演进
			VIP PaaS在接近两年时间里,基于kubernetes主要经历四次网络方案的变迁: 1. kubernetes + flannel 2. 基于Docker libnetwork的网络定制 3. k ... 
- lsscsi命令详解
			基础命令学习目录首页 lsscsi包默认是不安装的.lsscsi包安装完之后,lsscsi命令就可以使用了.lsscsi命令(lsscsi -t -L)能很方便的看出哪些是固态硬盘(SSD),哪些是S ... 
- Python面向对象-类成员
			类的成员可以分为三大类:字段.方法和属性: 注:所有成员中,只有普通字段的内容保存对象中,即:根据此类创建了多少对象,在内存中就有多少个普通字段.而其他的成员,则都是保存在类中,即:无论对象的多少,在 ... 
- android4.3 Bluetooth分析之扫描分析
			android4.3中引入了蓝牙低能耗le(low energy),相应的也有一些方法/类.不过代码里,并没有找到初始调用的地方.所以这里还是先只分析下bt普通的扫描流程(类似android 4.2) ... 
- iOS- 网络访问两种常用方式【GET & POST】实现的几个主要步骤
			1.前言 上次,在博客里谈谈了[GET & POST]的区别,这次准备主要是分享一下自己对[GET & POST]的理解和实现的主要步骤. 在这就不多废话了,直接进主题,有什么不足的欢 ... 
- c语言作业1
