#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn = ;
char str[maxn]; struct node{
char s[];
int year;
}p[maxn]; int cmp(node A, node B)
{
return A.year > B.year; //不要忽略这个细节,可能你会习惯性的用小于号。
} int main()
{
int t, n;
scanf("%d", &t);
while(t --)
{
scanf("%d", &n);
getchar(); //吃掉回车
for(int i = ; i < n; i++)
{
gets(str); //明显用gets(),scanf()连空格都不吃
int len = strlen(str);
p[i].year = ;
for(int j = len - ; j <= len - ; j++) p[i].year = * p[i].year + str[j] - '';
for(int j = ; j < len - ; j++) p[i].s[j] = str[j];
p[i].s[len-] = '\0'; //极为关键的一步,必须标记字符串结束标志,不然会多输出一些字符。
}
sort(p, p + n, cmp);
for(int i = ; i < n; i++) printf("%s\n", p[i].s);
}
return ;
}

HDU5427的更多相关文章

随机推荐

  1. D&F学数据结构系列——B树(B-树和B+树)介绍

    B树 定义:一棵B树T是具有如下性质的有根树: 1)每个节点X有以下域: a)n[x],当前存储在X节点中的关键字数, b)n[x]个关键字本身,以非降序存放,因此key1[x]<=key2[x ...

  2. Codeforces Round #259 (Div. 2) C - Little Pony and Expected Maximum (数学期望)

    题目链接 题意 : 一个m面的骰子,掷n次,问得到最大值的期望. 思路 : 数学期望,离散时的公式是E(X) = X1*p(X1) + X2*p(X2) + …… + Xn*p(Xn) p(xi)的是 ...

  3. JDBC第一次学习

     JDBC(Java Data Base Connectivity,java数据库连接),由一些类和接口构成的API,它是J2SE的一部分,由java.sql,javax.sql包组成. 应用程序.J ...

  4. ring0 与 ring3 层之间的交互

    在进行Windows的ring0层开发时,必不可免的要与 ring3 层进行交互.进行数据间的相互传输.可用的方法有DeviceIoCntrol,ReadFile.我平常都是用的DeviceIoCon ...

  5. JS之类型转换

    一.显示类型转换 1.Boolean() (1).undefined/null/‘’   ==> false (2).任何对象(包括例如var obj = {} ) ==>  true ( ...

  6. linq 常用语句

    自己练习的 switch (productDataAnalysisQuery.DataType) { : var data = (from hp in GPEcontext.hbl_product j ...

  7. Include Native *.so Library in APK With Android Studio

    Originally posted on:http://www.kylethielk.com/blog/include-native-so-library-in-apk-with-android-st ...

  8. C++ 读取REG_SZ 、REG_DWORD 、REG_MULTI_SZ 类型注册表值

    读取REG_SZ 类型的注册表键值 // 读取 REG_SZ 类型键值的代码 HKEY hKey = NULL; DWORD dwSize = ; DWORD dwDataType = ; LPBYT ...

  9. javamail邮件中插入图片

    转载 http://duanmumu.blog.163.com/blog/static/1911133502012715104016481/ // TODO Auto-generated method ...

  10. Mysql笔记——DQL

    DQL就是数据查询语言,数据库执行DQL语句不会对数据进行改变,而是让数据库发送结果集给客户端. 语法: SELECTselection_list /*要查询的列名称*/ FROM table_lis ...