A problem of sorting

Time Limit: 1 Sec

Memory Limit: 256 MB

题目连接

http://bestcoder.hdu.edu.cn/contests/contest_chineseproblem.php?cid=627&pid=1001

Description

给出一张许多人的年龄和生日表。你需要从年轻到年老输出人们的名字。(没有人年龄相同)

Input

第一行包含一个正整数T(T \leq 5)T(T≤5),表示数据组数。
对于每组数据,第一行包含一个正整数n(1 \leq n \leq 100)n(1≤n≤100),表示人数,接下来n行,每行包含一个姓名和生日年份(1900-2015),用一个空格隔开。姓名长度大于0且不大于100。注意姓名中只包含字母,数字和空格。

Output

对于每组数据,输出nn行姓名。

Sample Input

FancyCoder
xyz111
FancyCoder

Sample Output

HINT

 

题意

排序,然后输出名字

从年轻到年老,名字中可能有空格

题解:

数字永远都是最后四个,所以处理一下就好了

代码:

//qscqesze
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <bitset>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define maxn 1000
#define mod 10007
#define eps 1e-9
int Num;
//const int inf=0x7fffffff; //§ß§é§à§é¨f§3
const int inf=0x3f3f3f3f;
inline ll read()
{
ll x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
//************************************************************************************** struct node
{
char s[];
int age;
}a[maxn];
int n;
int kiss[maxn];
bool cmp(int aa,int bb)
{
return a[aa].age>a[bb].age;
}
int main()
{
int t=read();
while(t--)
{
int n=read();
memset(kiss,,sizeof(kiss));
memset(a,,sizeof(a));
for(int i=;i<n;i++)
{
int len = ;
a[i].age=;
cin.getline(a[i].s,);
len = strlen(a[i].s);
for(int j=;j<=;j++)
a[i].age=a[i].age*+a[i].s[len-+j]-'';
a[i].s[len-]='\0';
kiss[i]=i;
}
sort(kiss,kiss+n,cmp);
for(int i=;i<n;i++)
printf("%s\n",a[kiss[i]].s);
}
}

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(字符排序)

    Problem Description There are many people's name and birth in a list.Your task is to print the name ...

  3. HDU 5832 A water problem(某水题)

    p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...

  4. HDU 2096 小明A+B --- 水题

    HDU 2096 /* HDU 2096 小明A+B --- 水题 */ #include <cstdio> int main() { #ifdef _LOCAL freopen(&quo ...

  5. CODE FESTIVAL 2017 qual B B - Problem Set【水题,stl map】

    CODE FESTIVAL 2017 qual B B - Problem Set 确实水题,但当时没想到map,用sort后逐个比较解决的,感觉麻烦些,虽然效率高很多.map确实好写点. 用map: ...

  6. hdu 2117:Just a Numble(水题,模拟除法运算)

    Just a Numble Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tot ...

  7. hdu 2050:折线分割平面(水题,递归)

    折线分割平面 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Subm ...

  8. hdu 2044:一只小蜜蜂...(水题,斐波那契数列)

    一只小蜜蜂... Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total Submission(s): Accepte ...

  9. [HDU 2602]Bone Collector ( 0-1背包水题 )

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2602 水题啊水题 还给我WA了好多次 因为我在j<w[i]的时候状态没有下传.. #includ ...

随机推荐

  1. Blog CSS

    你好 print("你好.") haode

  2. IIS部署网站

  3. hdu 3068(最长回文)

    题意:容易理解... 思路:可以用扩展kmp来做,但是我还没怎么弄懂,时间复杂度O(n*logn),而manacher算法,第一次听说,代码比较短,不难理解,和扩展kmp有点类似,时间复杂度为:O(n ...

  4. Android Dialog用法

    摘要: 创建对话框 一个对话框一般是一个出现在当前Activity之上的一个小窗口. 处于下面的Activity失去焦点, 对话框接受所有的用户交互. 对话框一般用于提示信息和与当前应用程序直接相关的 ...

  5. STL六大组件之——容器知识大扫盲

    STL中的容器主要涉及顺序容器类型:vector.list.deque,顺序容器适配器类型:stack.queue.priority_queue.标准库中的容器分为顺序容器和关联容器.顺序容器(seq ...

  6. 常用的正则表达式归纳—JavaScript正则表达式

    来源:http://www.ido321.com/856.html 1.正则优先级 首先看一下正则表达式的优先级,下表从最高优先级到最低优先级列出各种正则表达式操作符的优先权顺序: 2.常用的正则表达 ...

  7. [算法] 快速排序 Quick Sort

    快速排序(Quick Sort)使用分治法策略. 它的基本思想是:选择一个基准数,通过一趟排序将要排序的数据分割成独立的两部分:其中一部分的所有数据都比另外一部分的所有数据都要小.然后,再按此方法对这 ...

  8. MapReduce Kmeans聚类算法

    最近在网上查看用MapReduce实现的Kmeans算法,例子是不错,http://blog.csdn.net/jshayzf/article/details/22739063 但注释太少了,而且参数 ...

  9. python setup.py install 失败

    由于curl证书太老,所以无法找到一些对应的版本. 如下更新证书即可: curl http://curl.haxx.se/ca/cacert.pem > /etc/pki/tls/certs/c ...

  10. linux 系统常用命令

    临时性的完全关闭防火墙,可以不重启机器: #/etc/init.d/iptables status                ##查看防火墙状态 #/etc/init.d/iptable stop ...