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 ...
随机推荐
- Python类对象
python类对象 python类对象支持两种操作:属性引用和实例化. 属性引用 使用 Python 中所有属性引用所使用的标准语法: obj.name. 有效的属性名称是类对象被创建时存在于类命名空 ...
- Java学习 · 初识 面向对象基础一
面向对象基础 1.1面向过程与面向对象的区别 面向过程和面向对象二者都是思考问题的方式,再简单的事物时,可以线性思考时使用面向过程,但当事物较为复杂时,只能使用面向对象设计.但二者并不是对立的,在解决 ...
- SVG Sprite 使用Symbol元素制作ICON
介绍 SVG是一种全新的使用方式,应该说这才是未来的主流,也是平台目前推荐的用法.之前写过两篇关于CSS icon在页面显示的博客,后来了解到现在大多数前端团队和项目都在使用SVG Sprite这种方 ...
- HDFS essay 2 - Clarify Name Node / Checkpoint Node/ Backup Node
为什么想用英文写了?我获取知识.技术的大部分途径都是通过英文,所以按照自己的理解用英文写下来也比较容易,另外,很多term都是不能翻译的,如果要持续学习技术和知识,那就不但要习惯去阅读,听,还要写,说 ...
- SpringBoot在IntelliJ IDEA下for MAC 热加载
说在前面 热加载:文件内容变更服务器自动运行最新代码.实则在IDEA环境进行热部署后,下述过程一气呵成. 1代码变更,文件自动保存(IDEA自动保存代码,用户无需使用COMMAND+SAVE快捷键): ...
- 软件工程 作业part2 采访
Part 2 采访本课程往届同学(含外校和毕业生). 现代软件工程这门课已经上了好几年了,以前有很多学生做过团队项目(说不定包括本校的学生),请你们找一个以前的团队采访一下. 我采访的是2016级于淼 ...
- 初学c#(又要打代码了好难)
因为我原来从没有学过C#,所以要重新看一个语言的基本语法,仔细阅读了老师的作业要求,发现第一个10分的作业如果要用c语言写我是可以完成的,于是定个小目标就是在周日前完成作业的第一步.今天我在菜鸟教程的 ...
- BluetoothDevice详解
一. BluetoothDevice简介 1. 继承关系 public static Class BluetoothDevice extends Object implement Parcelable ...
- JavaScript初探系列之数组的基本操作
在程序语言中数组的重要性不言而喻,JavaScript中数组也是最常使用的对象之一,数组是值的有序集合,由于弱类型的原因,JavaScript中数组十分灵活.强大,不像是Java等强类型高级语言数组只 ...
- Java中I/O流之轮换流
Java 中的轮换流: 非常有用,可以把一个字节流转换成字符流. inputStreamReader, outputStreamReader Demo_1: import java.io.*; cla ...