HDU5427
#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的更多相关文章
随机推荐
- POJ 2021
#include <iostream> #include <string> #include <algorithm> #define MAXN 105 using ...
- jstl 的应用 java
JSTL :JSP Standard Tag Library,JSP标准标签库 1.导入包 jstl.jar standard.jar 2.页面中添加标识 <%@taglib uri=" ...
- sql openxml sp_xml_preparedocument xml 中文乱码
DECLARE @xmlText xml ,@idoc int set @xmlText = (select doc from openrowset(bulk 'C:\Word\SRC\WebApp\ ...
- Linux问题定位工具大放送
我们在程序定位问题时,经常不知所错,但是在linux有很多强大的工具,只要我们合理利用,一定见奇效. 主要会遇到以下问题: 1 mem高 2 cpu高 3 io高 4 网络延迟高 vargrind:h ...
- LR_问题_平均响应时间解释,summary与analysis不一致
Summary Report中的时间说明 Summary是按整个场景的时间来做平均的,最大最小值,也是从整个场景中取出来的. (1) 平均响应时间:事物全部响应时间做平均计算 (2) ...
- C#与USB HID间的通信
原文:C#与USB HID间的通信 C#与USBHID接口的通讯相对于与串口间的通讯较为复杂,其中需要多次调用到Windows的一些API.其原理编者尚未全部理清,以下提供简单的USBHID通讯流程. ...
- iOS 安装使用cocoapods
一.什么是CocoaPods 1.为什么需要CocoaPods 在进行iOS开发的时候,总免不了使用第三方的开源库,比如SBJson.AFNetworking.Reachability等等.使用这些库 ...
- Android 广播机制(两种注册方法)与中断广播
两种注册类型的区别是: 1)第一种不是常驻型广播,也就是说广播跟随activity的生命周期.注意: 在activity结束前,移除广播接收器. 2)第二种是常驻型,也就是说当应用程序关闭后,如果有信 ...
- 关于Linux操作系统下文件特殊权限的解释
文件特殊权限的解释. -rwsr-xr-x = 4755 文件执行的时候,会以owner的身份来执行,就是setuid . 例如:-rwxr-xr-t 1 root wheel 0 7 9 18:24 ...
- centos 安装jdk
不要使用yum 安装openjdk,他妈的就是一坑货 首先到官网下载jdk,http://www.oracle.com/technetwork/java/javase/downloads/jdk7-d ...