hdu 5427(水)
2015-10-02 14:49
337 查看
题意:按照年龄从小到大排序
名字中可能有空格什么的,处理下即可
名字中可能有空格什么的,处理下即可
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; typedef long long ll; #define maxn 105 #define mod 1000000007 char tt[150]; struct node { int x; char id[105]; } pnode[maxn]; bool cmp(node a,node b) { return a.x > b.x; } int main() { int T; scanf("%d",&T); getchar(); while(T--) { int n; scanf("%d",&n); getchar(); for(int i = 1; i <= n; i++) { gets(tt); int len = strlen(tt); int num = 0; for(int j = len-4; j < len; j++) num = num*10+(tt[j] - '0'); pnode[i].x = num; for(int j = 0;j < len - 5;j++) pnode[i].id[j] = tt[j]; pnode[i].id[len-5] = '\0'; } sort(pnode+1,pnode+n+1,cmp); for(int i = 1;i <= n;i++) printf("%s\n",pnode[i].id); } return 0; }
相关文章推荐
- noip2012 摆花 (动态规划)
- [C++]只存储整型的无锁队列
- hdu 5427(水)
- JavaScript判断各浏览器CSS前缀的两种方式
- web前端,标签切换总结5load()加载新的html界面
- 安卓控件使用系列10:RadioButton单选按钮的使用
- 微信二维码 场景二维码 用于推送事件,关注等 注册用户 ,经过测试。。windows下面
- 分享一下Python 开发者节省时间的10个方法
- 表单中文数据提交到MySQL数据库乱码问题(已解决)
- C++中的结构到底可不可以继承?
- Android Studio启动配置gradle遇到的问题
- java 加载数据库驱动 与forname无关
- web前端,标签切换总结4removeClass() 去除元素的类
- Navicat Premium for mac 11.0 中文破解版安装
- えええ
- 网站性能测试
- C语言scanf()函数:格式化输入函数
- 接口
- 采用JSP+JavaBean的方式进行简单的实现用户的网页登陆实例
- 采用JSP+JavaBean的方式进行简单的实现用户的网页登陆实例