hdu 5427 A problem of sorting 水题
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 水题的更多相关文章
- 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(字符排序)
Problem Description There are many people's name and birth in a list.Your task is to print the name ...
- HDU 5832 A water problem(某水题)
p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...
- HDU 2096 小明A+B --- 水题
HDU 2096 /* HDU 2096 小明A+B --- 水题 */ #include <cstdio> int main() { #ifdef _LOCAL freopen(&quo ...
- CODE FESTIVAL 2017 qual B B - Problem Set【水题,stl map】
CODE FESTIVAL 2017 qual B B - Problem Set 确实水题,但当时没想到map,用sort后逐个比较解决的,感觉麻烦些,虽然效率高很多.map确实好写点. 用map: ...
- hdu 2117:Just a Numble(水题,模拟除法运算)
Just a Numble Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tot ...
- hdu 2050:折线分割平面(水题,递归)
折线分割平面 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Subm ...
- hdu 2044:一只小蜜蜂...(水题,斐波那契数列)
一只小蜜蜂... Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total Submission(s): Accepte ...
- [HDU 2602]Bone Collector ( 0-1背包水题 )
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2602 水题啊水题 还给我WA了好多次 因为我在j<w[i]的时候状态没有下传.. #includ ...
随机推荐
- 【转】eclipse中egit插件使用
原文网址:http://my.oschina.net/songxinqiang/blog/192567 eclipse和git这个两个工具的使用人数都是相当多的,在eclipse里面也有egit插件来 ...
- 用命令行(CMD)中启动和关闭ORACLE服务
lsnrctl start开启监听 lsnrctl stop停止监听 net start oracleserviceoracle开启oracle服务 net stop oracleserviceora ...
- hdu 2870(dp求最大子矩阵)
题意:让你求的是由同一字母组成的最大子矩阵,w可以变成a或者b,x可以变成b或者c,y可以变成a或者c,z可以变成a或者b或者c. 分析:这是hdu 1506.hdu 1505的加强版,具体的分析看我 ...
- [Papers]NSE, $u_3$, Lebesgue space [Zhou-Pokorny, Nonlinearity, 2009]
$$\bex u_3\in L^p(0,T;L^q(\bbR^3)),\quad \frac{2}{p}+\frac{3}{q}=\frac{3}{4}+\frac{1}{2q},\quad \fra ...
- Codeforces Round #361 (Div. 2) 套题
A - Mike and Cellphone 问有没有多解,每个点按照给出的序列用向量法跑一遍 #include<cstdio> #include<cstring> #incl ...
- Mahout踩坑之路
一.版本对比 公司版Mahout 由于Mahout只能允许于hadoop0.20以上版本上,而百度的hadoop是hadoop0.19的一个分支.因此百度HPC组曾经将Mahout移植到百度的hado ...
- linux下mysql数据库的学习
转载博客:http://freedomljtt.blog.163.com/blog/static/72294949201210145441701/ ubuntu12.04 卸载和安装mysql 卸载m ...
- Integer做WeakHashMap的Key应注意的问题
WeakHashMap使用弱引用来作为Map的Key,利用虚拟机的垃圾回收机制能自动释放Map中没有被使用的条目.但是WeakHashMap释放条目是有条件的:首先条目的Key在系统中没有强引用指向: ...
- vmware ubuntu14.04虚拟机不能正常拷贝文件到windows且不能自适应虚拟机屏幕窗口自动变化的解决办法
纠结于这个问题了半天.一直重复安装不同版本的vmare-tools, 一直没有任何效果.进入到/usr/bin/ 目录使用ll vm* 查看,发现和别的不同的是没有vmware-toolbox-cmd ...
- java中的==和equals的区别
关于JAVA中的==和equals函数的区别 今天在研读Thinking in java 时注意到==和equals的区别,于是就通过查看JDK_API才读懂了他们的区别,于是将心得分享一下,望批评指 ...