Problem 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≤ 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).
Output
For each case, output n lines.
 
Sample Input

FancyCoder  

FancyCoder
xyz111
 
Sample Output
FancyCoder
xyz111
FancyCoder
 
Source
 
具体看代码
 #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(字符排序)的更多相关文章

  1. hdu 5427 A problem of sorting

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5427 A problem of sorting Description There are many ...

  2. hdu 5427 A problem of sorting 水题

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

  3. hdu.5195.DZY Loves Topological Sorting(topo排序 && 贪心)

    DZY Loves Topological Sorting Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 ...

  4. HDU 5195 DZY Loves Topological Sorting 拓扑排序

    题目链接: hdu:http://acm.hdu.edu.cn/showproblem.php?pid=5195 bc(中文):http://bestcoder.hdu.edu.cn/contests ...

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

  6. HDU 2087 剪花布条(字符串匹配,KMP)

    HDU 2087 剪花布条(字符串匹配,KMP) Description 一块花布条,里面有些图案,另有一块直接可用的小饰条,里面也有一些图案.对于给定的花布条和小饰条,计算一下能从花布条中尽可能剪出 ...

  7. 实验12:Problem C: 重载字符的加减法

    Home Web Board ProblemSet Standing Status Statistics   Problem C: 重载字符的加减法 Problem C: 重载字符的加减法 Time ...

  8. HDU 3549 Flow Problem(最大流)

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

  9. BZOJ1697: [Usaco2007 Feb]Cow Sorting牛排序

    1697: [Usaco2007 Feb]Cow Sorting牛排序 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 387  Solved: 215[S ...

随机推荐

  1. github atom 试用

    github的编辑器atom 1.0已经出来了,在https://atom.io/ 我之前在win上一直用notepad++写了两年脚本.最近改写lua了,项目组统一用的sublime text.su ...

  2. 【转载自i春秋】图片马合成方法

    1.将图片和一句话木马放在同一个文件夹 2.创建快捷方式,将起始位置修改为图片和txt文本的路径. 3.进行合成,命令如下 copy .png /b + .txt /a .png 4.成功!自行测试. ...

  3. WebService-相关概念介绍

    WebService学习总结(二)——WebService相关概念介绍 一.WebService是什么? 1. 基于Web的服务:服务器端整出一些资源让客户端应用访问(获取数据) 2. 一个跨语言.跨 ...

  4. 【git 问题小说说】 git add时候报错:LF will be replaced by CRLF

    本文来自:http://blog.csdn.net/loovejava/article/details/22114477 最近工作在window平台,不怎么使用命令行了所以导致很多命令都不熟悉啦 哈哈 ...

  5. C++ Primer 学习笔记_77_模板与泛型编程 --实例化

    模板与泛型编程 --实例化 引言: 模板是一个蓝图,它本身不是类或函数.编译器使用模板产生指定的类或函数的特定版本号.产生模板的特定类型实例的过程称为实例化. 模板在使用时将进行实例化,类模板在引用实 ...

  6. FragmentPagerAdapter与FragmentStatePagerAdapter差异

    平常使用的FragmentPagerAdapter和FragmentStatePagerAdapter来自android.support.v4.app包用来构建ViewPager. FragmentP ...

  7. Oracle关联查询关于left/right join的那点事

    /*题外话 --更改foreign key约束定义引用行(delete cascade/delete set null/delete no action),默认delete on action--引用 ...

  8. visifire 图表双坐标轴 silverlight

    public void CreateChart(Grid oGrid, ObservableCollection<ListItem> lBaseOilBar)        {       ...

  9. C# string的一些函数

    创建string: string (char[])      使用指定的字符串数组构建一个新的string对象 Copy(string) 使用指定的string构建一个新的string对象 比较函数: ...

  10. PHP MAIL DEMO(程序代码直接发送邮件)

    php代码 <?php // 收件人邮箱地址 $to = 'xxxxxx@qq.com'; // 邮件主题 $title = '测试邮件发送'; // 邮件内容 $msg = '这是一封测试邮件 ...