UVa Age Sort 11462(排序技巧)
2016-02-26 16:33
495 查看
Age Sort
You are given the ages (in years) of all people of a country with at least 1 year of age. You know thatno individual in that country lives for 100 or more years. Now, you are given a very simple task ofsorting all the ages in ascending order.
Input
There are multiple test cases in the input file. Each case starts with an integer n (0 < n ≤ 2000000), thetotal number of people. In the next line, there are n integers indicating the ages. Input is terminatedwith a case where n = 0. This case should not
be processed.
Output
For each case, print a line with n space separated integers. These integers are the ages of that countrysorted in ascending order.Warning: Input Data is pretty big (∼ 25 MB) so use faster IO.
Sample Input
5
3 4 2 1 5
5
2 3 2 3 10
Sample Output
1 2 3 4 5
1 2 2 3 3
You are given the ages (in years) of all people of a country with at least 1 year of age. You know thatno individual in that country lives for 100 or more years. Now, you are given a very simple task ofsorting all the ages in ascending order.
Input
There are multiple test cases in the input file. Each case starts with an integer n (0 < n ≤ 2000000), thetotal number of people. In the next line, there are n integers indicating the ages. Input is terminatedwith a case where n = 0. This case should not
be processed.
Output
For each case, print a line with n space separated integers. These integers are the ages of that countrysorted in ascending order.Warning: Input Data is pretty big (∼ 25 MB) so use faster IO.
Sample Input
5
3 4 2 1 5
5
2 3 2 3 10
Sample Output
1 2 3 4 5
1 2 2 3 3
#include<stdio.h> #include<string.h> #include<algorithm> #define INF 0x3f3f3f3f #define N 10010 #define ll long long using namespace std; int a[110]; int main() { int n,m,i,j,k; while(scanf("%d",&n),n) { memset(a,0,sizeof(a)); for(i=0;i<n;i++) { scanf("%d",&m); a[m]++; } int tmp=1; for(i=1;i<=100;i++) { for(j=0;j<a[i];j++) { if(!tmp) printf(" "); tmp=0; printf("%d",i); } } printf("\n"); } return 0; }
相关文章推荐
- php编辑器中图文并茂处理
- effective js-10-避免使用with
- 强制删除DBF文件导致数据库报“ORA-01033: ORACLE 正在初始化或关闭”错误
- React入门简单实践
- Downloading directory from FTP server
- Dubbo的提供者服务如何发布?
- ubuntu svn服务搭建记录
- 微信消息接口发送信息到分组和用户,错误代码40003和40008
- Unity3D 学习 控制角色运动控制
- CodeForces 616 D. Longest k-Good Segment(尺取)
- 一个Android Studio主题的网站
- 【华为悦读汇】技术发烧友:认识VXLAN
- Java的方法签名
- java 直接插入排序
- 《计算机网络原理》之宏观理解
- python终极解决UnicodeEncodeError
- Android 编程下 Touch 事件的分发和消费机制(下)
- 父页面调用iframe中的js方法
- linux网桥
- Guess the Permutation