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 用增广路算法 ...
随机推荐
- Flash图表控件FusionCharts如何定制图表中的趋势线和趋势区
FusionCharts中的趋势线是什么 趋势线是横跨图标的水平/垂直线条,用来表示一些预订数据值. 在图表中展示趋势线 用户可以使用<chart>元素中的trendlines属性来显示图 ...
- 慕课网-安卓工程师初养成-3-6 Java中的逻辑运算符
来源: http://www.imooc.com/code/1301 逻辑运算符主要用于进行逻辑运算.Java 中常用的逻辑运算符如下表所示: 我们可以从“投票选举”的角度理解逻辑运算符: 1. 与: ...
- jquery是如何清除ajax缓存的
大家都知道万恶的IE在ajax中往往只读取第一次ajax请求时候的数据,其余时候都是从cache提取数据,(太懒了T_T).原生的JS清除ajax缓存的方法多,但是终觉有点繁琐,如果是用jquery的 ...
- OpenJudge 取数游戏
描述 我们来玩一个游戏:自然数1到N,按顺序列成一排,你可以从中取走任意个数,但是相邻的两个不可以同时被取走.如果你能算出一共有多少种取法,那么你会被天神Lijiganjun奖励. 输入 仅包含一个数 ...
- alter table <表名 > add constraint <主键名>用法
alter table <表名 > add constraint <主键名>用法介绍 1.主键约束: 要对一个列加主键约束的话,这列就必须要满足的条件就是分空 因为主键约束: ...
- iPad用户使用Mac和Windows应用软件-记Parallels Access使用体验
iPad用户使用Mac和Windows应用软件-记ParallelsAccess使用体验 用ipad远程连接win系统已不是新鲜事情,我们可以使用TeamViewer和OnLiveDesktopPlu ...
- PAT1013
#include<cstdio>#include<cstring>#include<vector>using namespace std;const int max ...
- chrome浏览器设置小于12号的字体不起作用?
在某些chrome浏览器下,css里设置的10号字体竟然不起作用!仍显示12号大小,对比firefox.ie6.7.8.9,他们的显示都是好的. 要是你也碰到这问题,可以这样解决: -webkit-t ...
- 【Linux】Zabbix + MPM + msmtp + mutt 监控MySQL + 邮件报警
Zabbix部署参考博文 http://blog.sina.com.cn/s/blog_5611597901017oe0.html MPM安装配置参考博文和MPM官网下载地址 http://blog ...
- iOS之UIAlertView的使用
UIAlertView: 1.普通使用: //普通的alert UIAlertView *av = [[UIAlertView alloc]initWithTitle:@"title&quo ...