题目连接

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的更多相关文章

  1. hdu 5427 A problem of sorting 水题

    A problem of sorting Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://bestcoder.hdu.edu.cn/contest ...

  2. 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 ...

  3. 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 ...

  4. HDU 3549 Flow Problem(最大流)

    HDU 3549 Flow Problem(最大流) Time Limit: 5000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/ ...

  5. hdu 5106 Bits Problem(数位dp)

    题目链接:hdu 5106 Bits Problem 题目大意:给定n和r,要求算出[0,r)之间全部n-onebit数的和. 解题思路:数位dp,一个ct表示个数,dp表示和,然后就剩下普通的数位d ...

  6. HDU 3374 String Problem (KMP+最大最小表示)

    HDU 3374 String Problem (KMP+最大最小表示) String Problem Time Limit: 2000/1000 MS (Java/Others)    Memory ...

  7. hdu 5105 Math Problem(数学)

    pid=5105" target="_blank" style="">题目链接:hdu 5105 Math Problem 题目大意:给定a.b ...

  8. Hdu 5445 Food Problem (2015长春网络赛 ACM/ICPC Asia Regional Changchun Online)

    题目链接: Hdu  5445 Food Problem 题目描述: 有n种甜点,每种都有三个属性(能量,空间,数目),有m辆卡车,每种都有是三个属性(空间,花费,数目).问至少运输p能量的甜点,花费 ...

  9. 网络流 HDU 3549 Flow Problem

    网络流 HDU 3549 Flow Problem 题目:pid=3549">http://acm.hdu.edu.cn/showproblem.php?pid=3549 用增广路算法 ...

随机推荐

  1. 学习总结 java连接数据库

    package com.hanqi.test; import java.sql.*; public class jdbcTest { public static void main(String[] ...

  2. struts2项目需要加入的jar包

    asm-3.3.jarasm-commons-3.3.jarasm-tree-3.3.jarcommons-fileupload-1.2.2.jarcommons-io-2.0.1.jarcommon ...

  3. MFC启动和关闭线程

    1. 启动线程: CWinThread* AfxBeginThread( 线程函数,this ); 2.通常导致线程终止的两种情况是:控制函数退出或不允许线程完成运行.如果字处理器使用后台打印线程,若 ...

  4. SVN与TortoiseSVN实战:文件加锁详解

    硬广:<SVN与TortoiseSVN实战>系列已经写了八篇,本篇是完结篇,整个系列结合TortoiseSVN对SVN中容易被忽视的部分进行了详解,以技巧性为主. 本篇详解使用Tortoi ...

  5. nc命令学习

    监测端口是否存在 nc -z 127.0.0.1 9100 扫描端口 nc -z -v 127.0.0.1 8000 9999 发送http nc www.baidu.com 80 GET / HTT ...

  6. 谈谈 React.js 的核心入门知识

    近来React.js变得越来越流行,本文就来谈一谈React.js的入门实践,通过分析一些常用的概念,以及提供一些入门 的最佳编程编程方式,仅供参考. 首先需要搞懂的是,React并不是一个框架,Re ...

  7. 使用buildroot编译bind DNS服务器

    用buildroot来制作文件系统很方便,编译出来的文件系统是直接可用的,不用添加脚本等麻烦的工作,很多的库和app都可以直接添加到文件系统里边,如常用的udhcpc,tftp,apache,ligh ...

  8. GUI_DOWNLOAD参数说明

    对FUNCTION: GUI_DOWNLOAD中某些参数的用法.       call function 'GUI_DOWNLOAD'     exporting *     BIN_FILESIZE ...

  9. 基于Vivado HLS在zedboard中的Sobel滤波算法实现

     基于Vivado HLS在zedboard中的Sobel滤波算法实现 平台:zedboard  + Webcam 工具:g++4.6  + VIVADO HLS  + XILINX EDK + ...

  10. node中的流程控制中,co,thunkify为什么return callback()可以做到流程控制?

    前言 我在学习generator ,yield ,co,thunkify的时候,有许多费解的地方,经过了许多的实践,也慢慢学会用,慢慢的理解,前一阵子有个其他项目的同事过来我们项目组学习node,发现 ...