hdu 5427 A problem of sorting
题目连接
http://acm.hdu.edu.cn/showproblem.php?pid=5427
A problem of sorting
Description
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.)
Input
First line contains a single integer $T \leq 100$ which denotes the number of test cases.
For each test case, there is an positive integer $n\ (1 \leq n \leq 100)$ which denotes the number of people,and next $n$ 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 100.Notice name only contain letter(s),digit(s) and space(s).
Output
For each case, output $n$ lines.
Sample Input
2
1
FancyCoder 1996
2
FancyCoder 1996
xyz111 1997
Sample Output
FancyCoder
xyz111
FancyCoder
字符串简单题。。
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include<set>
using std::set;
using std::sort;
using std::pair;
using std::swap;
using std::queue;
using std::multiset;
#define pb(e) push_back(e)
#define sz(c) (int)(c).size()
#define mp(a, b) make_pair(a, b)
#define all(c) (c).begin(), (c).end()
#define iter(c) decltype((c).begin())
#define cls(arr, val) memset(arr, val, sizeof(arr))
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define tr(c, i) for(iter(c) i = (c).begin(); i != (c).end(); ++i)
const int N = 110;
const int INF = 0x3f3f3f3f;
typedef unsigned long long ull;
struct Node {
int age;
char name[N];
inline bool operator<(const Node &x) const {
return age > x.age;
}
}A[N];
int main() {
#ifdef LOCAL
freopen("in.txt", "r", stdin);
freopen("out.txt", "w+", stdout);
#endif
int t, n;
char buf[200], digit[5];
scanf("%d", &t);
while (t--) {
scanf("%d", &n);
getchar();
rep(i, n) {
gets(buf);
int v, j = 0, len = strlen(buf);
for (; j < 4; j++) digit[j] = buf[len - 4 + j];
digit[j] = '\0'; v = atoi(digit);
buf[len - 5] = '\0';
A[i].age = v, strcpy(A[i].name, buf);
}
sort(A, A + n);
rep(i, n) printf("%s\n", A[i].name);
}
return 0;
}
hdu 5427 A problem of sorting的更多相关文章
- hdu 5427 A problem of sorting 水题
A problem of sorting Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://bestcoder.hdu.edu.cn/contest ...
- hdu 5427 A problem of sorting(字符排序)
Problem Description There are many people's name and birth in a list.Your task is to print the name ...
- hdu 5195 DZY Loves Topological Sorting BestCoder Round #35 1002 [ 拓扑排序 + 优先队列 || 线段树 ]
传送门 DZY Loves Topological Sorting Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131 ...
- HDU 3549 Flow Problem(最大流)
HDU 3549 Flow Problem(最大流) Time Limit: 5000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/ ...
- hdu 5106 Bits Problem(数位dp)
题目链接:hdu 5106 Bits Problem 题目大意:给定n和r,要求算出[0,r)之间全部n-onebit数的和. 解题思路:数位dp,一个ct表示个数,dp表示和,然后就剩下普通的数位d ...
- HDU 3374 String Problem (KMP+最大最小表示)
HDU 3374 String Problem (KMP+最大最小表示) String Problem Time Limit: 2000/1000 MS (Java/Others) Memory ...
- hdu 5105 Math Problem(数学)
pid=5105" target="_blank" style="">题目链接:hdu 5105 Math Problem 题目大意:给定a.b ...
- Hdu 5445 Food Problem (2015长春网络赛 ACM/ICPC Asia Regional Changchun Online)
题目链接: Hdu 5445 Food Problem 题目描述: 有n种甜点,每种都有三个属性(能量,空间,数目),有m辆卡车,每种都有是三个属性(空间,花费,数目).问至少运输p能量的甜点,花费 ...
- 网络流 HDU 3549 Flow Problem
网络流 HDU 3549 Flow Problem 题目:pid=3549">http://acm.hdu.edu.cn/showproblem.php?pid=3549 用增广路算法 ...
随机推荐
- 【LeetCode】21. Merge Two Sorted Lists
题目: Merge two sorted linked lists and return it as a new list. The new list should be made by splici ...
- IOS thread1:exc_bad)access(code=exc_1386_gpflt)错误
这种错误通常是内存管理的问题,一般是访问了已经释放的对象导致的,可以开启僵尸对象(Zombie Objects)来定位问题: 在Xcode的菜单: Product->Scheme->Edi ...
- Web 站点的水平扩展和垂直扩展 (译文)
当一个开发人员提升计算机系统负荷时,通常会考虑两种方式垂直扩展和水平扩展.选 用哪种策略主要依赖于要解决的问题以及系统资源的限制.在这篇文章中我们将讲述这两种策略并讨论每种策越的优缺点.如果你已经有一 ...
- [Oracle] 中的Temporary tablespace的作用
临时表空间主要用途是在数据库进行排序运算[如创建索引.order by及group by.distinct.union/intersect/minus/.sort-merge及join.analyze ...
- http协议状态码对照表
1**:请求收到,继续处理 2**:操作成功收到,分析.接受 3**:完成此请求必须进一步处理 4**:请求包含一个错误语法或不能完成 5**:服务器执行一个完全有效请求失败 100——客户必须继续发 ...
- Code Sign error: No unexpired provisioning profiles found that contain any of the keychain's signing certificates
最近离职了,刚好在离职之际有人叫我帮做个项目,简直了,没有mac电脑,没有真ji设备,简直了.接项目那哥们,暂且叫做J,大哥说我给你想办法,then,给借了个mac pro.刚拿到电脑真是喜出望外啊, ...
- WP8_Json的用法
WP从服务器.API交换数据一般都是用JSON格式字符串. 下面介绍用Newtonsoft.Json来处理JSON. 准备 1.到 http://json.codeplex.com/ 下载Newton ...
- 深入理解JavaScript系列(转自汤姆大叔)
深入理解JavaScript系列文章,包括了原创,翻译,转载,整理等各类型文章,如果对你有用,请推荐支持一把,给大叔写作的动力. 深入理解JavaScript系列(1):编写高质量JavaScript ...
- vim中查找指定字符串
0x01 自当前光标位置向上搜索 /pattern Enter (pattern表示要搜索的字符串) 0x02 自当前光标位置向下搜索 ?pattern Enter 0x03 n继续从同 ...
- HTML与XHTML的区别
为什么要使用XHTML? 我们认为万维网上的许多页面都包含着糟糕的 HTML 代码. 下面的 HTML 代码仍然可以工作得很好,即使它没有遵守 HTML 规则: <html> <he ...