hdu 5427 A problem of sorting(字符排序)
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.)
First line contains a single integer T≤ which denotes the number of test cases. For each test case, there is an positive integer n(≤n≤) 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 .Notice name only contain letter(s),digit(s) and space(s).
For each case, output n lines.
FancyCoder FancyCoder
xyz111
FancyCoder
xyz111
FancyCoder
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<cmath>
using namespace std;
#define N 106
int n;
struct Node{
int year;
char ch[];
}person[N];
bool cmp(Node a,Node b){
return a.year>b.year;
}
int main()
{
int t;
scanf("%d",&t);
while(t--){
scanf("%d",&n);
char s[];
getchar();
for(int i=;i<n;i++){
person[i].year=;
gets(s);
//puts(s);
int len=strlen(s);
for(int j=;j<len-;j++){
person[i].ch[j]=s[j];
}
person[i].ch[len-]='\0';//记得加,否则wa for(int j=len-;j<len;j++){
person[i].year=person[i].year*+s[j]-'';
}
//printf("%s\n",person[i].ch);
//printf("%d\n",person[i].year);
}
sort(person,person+n,cmp);
for(int i=;i<n;i++){
printf("%s\n",person[i].ch);
}
} return ;
}
hdu 5427 A problem of sorting(字符排序)的更多相关文章
- hdu 5427 A problem of sorting
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5427 A problem of sorting Description There are many ...
- 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.5195.DZY Loves Topological Sorting(topo排序 && 贪心)
DZY Loves Topological Sorting Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 ...
- HDU 5195 DZY Loves Topological Sorting 拓扑排序
题目链接: hdu:http://acm.hdu.edu.cn/showproblem.php?pid=5195 bc(中文):http://bestcoder.hdu.edu.cn/contests ...
- 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 2087 剪花布条(字符串匹配,KMP)
HDU 2087 剪花布条(字符串匹配,KMP) Description 一块花布条,里面有些图案,另有一块直接可用的小饰条,里面也有一些图案.对于给定的花布条和小饰条,计算一下能从花布条中尽可能剪出 ...
- 实验12:Problem C: 重载字符的加减法
Home Web Board ProblemSet Standing Status Statistics Problem C: 重载字符的加减法 Problem C: 重载字符的加减法 Time ...
- HDU 3549 Flow Problem(最大流)
HDU 3549 Flow Problem(最大流) Time Limit: 5000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/ ...
- BZOJ1697: [Usaco2007 Feb]Cow Sorting牛排序
1697: [Usaco2007 Feb]Cow Sorting牛排序 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 387 Solved: 215[S ...
随机推荐
- socket 发送Ping包
参考链接: http://blog.csdn.net/zpxili/article/details/11542041 http://blog.csdn.net/cbuttonst/article/de ...
- 如何将EXCEL表导入MYSQL
在平时的工作学习中,难免会遇到需要把EXCEL表中的数据导入到MYSQL中,比如要把EXCEL中的数据进行核对,或者要把测试用例导入到TestLink中.本人搜集相关的资料并加以实践总 ...
- 压位加速-poj-2443-Set Operation
题目链接: http://poj.org/problem?id=2443 题目意思: 有n个集合(n<=1000),每个集合有m个数ai(m<=10000,1=<ai<=100 ...
- [Javascript] Regex: '$`', '$&', '$''
var input = "foobar"; var result = input.replace('bar', '$`'); // $`: replace 'bar' with e ...
- Android中Service类onStartCommand
Android开发的过程中,每次调用startService(Intent)的时候,都会调用该Service对象的onStartCommand(Intent,int,int)方法,然后在onStart ...
- js_day8
- java基础之代理
代理的定义,代理的应用,代理的特性
- ios开发必备第三方库
引言 作为iOS开发人员,在开发App的过程中怎么会不使用第三方库呢?相信没有App是不使用第三方库的! 网络库 网络库,这是开发必备,除非你的App玩单机.现在特别火也特别好用的网络库就数AFNet ...
- IIS负载均衡相关
1. IIS负载均衡 (比较简单的例子,能看到效果) 2.nginx+iis实现负载均衡 3.Windows平台分布式架构实践 - 负载均衡 4.Net分布式系统:Keepalived+LVS+Ngi ...
- [原创]旧事重提:只配置参数实现OAuth2登录
其实这个组件写出来很长时间了,有几个月吧,一直在 MrHuo工作室 上放着,一直说要整理,太忙没时间. 另外,关于OAuth2的一些基础内容还请从网上找找资料,太多了,写的累赘. 废话不多说,先上图 ...