HDOJ 5427 A problem of sorting
来源:互联网 发布:web安全编程 编辑:程序博客网 时间:2024/06/05 09:09
A problem of sorting
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1215 Accepted Submission(s): 485
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≤100 which denotes the number of test cases.
For each test case, there is an positive integern(1≤n≤100) 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 than100 .Notice name only contain letter(s),digit(s) and space(s).
For each test case, there is an positive integer
The length of name is positive and not larger than
Output
For each case, output n lines.
Sample Input
21FancyCoder 19962FancyCoder 1996xyz111 1997
Sample Output
FancyCoderxyz111FancyCoder题意:给出一张许多人的年龄和生日表。你需要从年轻到年老输出人们的名字。(没有人年龄相同)注意:姓名可以含有空格ac代码:#include<stdio.h>#include<math.h>#include<string.h>#include<stack>#include<queue>#include<iostream>#include<algorithm>#define MAXN 10001#define LL long long#define INF 0x7fffffff#define mem(x) memset(x,0,sizeof(x))using namespace std;struct s{char name[110];int num;}a[110];bool cmp(s a,s b){return a.num>b.num;}int main(){int t,i,j;int n;char ss[1010];char str[1010];scanf("%d",&t);while(t--){scanf("%d",&n);getchar();for(i=0;i<n;i++){gets(ss);//printf("yes\n");int len=strlen(ss);int q=0;int k=1;int w=0;int bz=0;for(j=len-1;j>=0;j--){if(ss[j]==' '&&bz==0){bz=1;continue;}if(bz){str[w++]=ss[j];}else{q=q+(ss[j]-'0')*k;k*=10;}}a[i].num=q;k=0;for(j=w-1;j>=0;j--)a[i].name[k++]=str[j];a[i].name[k]='\0';//getchar();}sort(a,a+n,cmp);for(i=0;i<n;i++)printf("%s\n",a[i].name);}return 0;}
0 0
- HDOJ 5427 A problem of sorting
- A problem of sorting
- BestCoder Round #54 (div.2) HDOJ 5427 A problem of sorting(模拟)
- hdu 5427 A problem of sorting
- hdu 5427 A problem of sorting 排序
- HDU 5427 A problem of sorting 水题
- hdu 5427 A problem of sorting
- hdu 5427 A problem of sorting
- HDU 5427 A problem of sorting
- HDU 5427 A problem of sorting
- hdu 5427 A problem of sorting 排序
- hdu 5427 A problem of sorting(水)
- HDU5429----A problem of sorting
- hdu 5427 A problem of sorting 解题报告
- HDU 5427-A problem of sorting(字符串处理)
- 【map容器+string】hdu 5427 A problem of sorting
- HDU——5427 A problem of sorting
- BC - A problem of sorting(模拟题)
- android源码下载地址
- 第一个web自动化
- Git教程
- KMP算法--c语言实现
- iOS 开发笔记和技巧总结 (四)
- HDOJ 5427 A problem of sorting
- Android应用启动优化:一种DelayLoad的实现和原理
- linux命令学习(5):rmdir命令(删除空目录)
- C#单例模式的三种写法
- Chicken Soup 【我的blog今天有排名了,很开森】
- PHP字符串处理函数库
- C-032.指针为什么也要分类型
- 用 LeakCanary 检测内存泄漏
- WebAPI CORS 支持跨域POST