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 1

0

Sample Output

1 2 3 4 5

1 2 2 3 3

#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std; int compare(int x, int y)
{
return x < y;
} int a[2000010]; int main()
{
int n;
while (scanf("%d",&n) && n)
{
for (int i=0; i<n; i++)
scanf("%d",&a[i]);
sort(a,a+n,compare);
printf("%d",a[0]);
for (int i=1; i<n; i++)
printf(" %d",a[i]);
printf("\n");
}
return 0; }

hbmy周赛1--A的更多相关文章

  1. hbmy周赛1--E

    E - Combination Lock Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I6 ...

  2. hbmy周赛1--D

    D - Toy Cars Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submi ...

  3. hbmy周赛1--C

    C - Exam Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit St ...

  4. hbmy周赛1--B

    B - 改革春风吹满地 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit  ...

  5. 周赛-KIDx's Pagination 分类: 比赛 2015-08-02 08:23 7人阅读 评论(0) 收藏

    KIDx's Pagination Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others) S ...

  6. 2015浙江财经大学ACM有奖周赛(一) 题解报告

    2015浙江财经大学ACM有奖周赛(一) 题解报告 命题:丽丽&&黑鸡 这是命题者原话. 题目涉及的知识面比较广泛,有深度优先搜索.广度优先搜索.数学题.几何题.贪心算法.枚举.二进制 ...

  7. Leetcode 第133场周赛解题报告

    今天参加了leetcode的周赛,算法比赛,要求速度比较快.有思路就立马启动,不会纠结是否有更好的方法或代码可读性.只要在算法复杂度数量级内,基本上是怎么实现快速就怎么来了. 比赛时先看的第二题,一看 ...

  8. 牛客OI周赛9-提高组题目记录

    牛客OI周赛9-提高组题目记录 昨天晚上做了这一套比赛,觉得题目质量挺高,而且有一些非常有趣而且非常清奇的脑回路在里边,于是记录在此. T1: 扫雷 题目链接 设 \(f_i\) 表示扫到第 \(i\ ...

  9. codeforces 14A - Letter & codeforces 859B - Lazy Security Guard - [周赛水题]

    就像title说的,是昨天(2017/9/17)周赛的两道水题…… 题目链接:http://codeforces.com/problemset/problem/14/A time limit per ...

随机推荐

  1. java I/O---复制文本文件

    利用FileInputStream 和FileOutputStream 复制文本 1 public class CopyTextByBuffer { 2 3 /** 4 * @param args 5 ...

  2. tesserat训练中文备忘录

    最近用OCR识别身份证,用的tesseract引擎.但是google自带的中文库是在太慢了,尤其是对于性别.民族这样结果可以穷举的特征信息而言,完全可以自己训练字库.自己训练字库不仅可以提高识别速度, ...

  3. bzoj 1150: [CTSC2007]数据备份Backup

    Description 你在一家 IT 公司为大型写字楼或办公楼(offices)的计算机数据做备份.然而数据备份的工作是枯燥乏味 的,因此你想设计一个系统让不同的办公楼彼此之间互相备份,而你则坐在家 ...

  4. Oracle 启动参数

    查看数据库的SID DB_NAME SERVICE_NAME

  5. Extjs 取消backspace事件

    Ext.getDoc().on('keydown',function(e){ if(e.getKey() == 8 && e.getTarget().type =='text' &am ...

  6. 深入理解 React JS 中的 setState

    此文主要探讨了 React JS 中的 setState 背后的机制,供深入学习 React 研究之用. 在课程 React.js入门基础与案例开发 中,有些同学会发现 React JS 中的 set ...

  7. 例子:web版坦克大战1.0

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  8. 消息队列一:为什么需要消息队列(MQ)?

    为什么会需要消息队列(MQ)? #################################################################################### ...

  9. 房上的猫:while循环与do-while循环,debug的调试运用

    一.循环结构 1.循环不是无休止进行的,满足一定条件的时候循环才会继续,称为"循环条件",循环条件不满足的时候,循环退出 2.循环结构是反复进行相同的或类似的一系列操作,称为&qu ...

  10. 学习整理与细化(2)——HTML VS XHTML

    <html> <head>//文档头 <title>webpage title</title> </head> <body>// ...