1.


/**
* Angewandte Mathematik, SS09, IFB 2C
* ACM Problem: Age Sort (11462)
* @author Christian Mitterreiter
* @author Rolf Luigs
* @version 1.0, 06/15/2009
* Status : Accepted
* Runtime: 3.224
*/


import java.util.Scanner;


public class Main {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);
StringBuilder out = new StringBuilder();
int count = sc.nextInt(); //einlesen, der zu erwartenden Zahlen

while(true) {

short[] in = new short[10000];

/**
* für jede eingelesene Zahl wird an ihrer Stelle im
* Array der entsprechene Index um 1 erhöht.
*/
for(int i = 0; i<count;i++) {
in[sc.nextInt()]++;
}

for(int j = 0; j<in.length;j++) {
if(in[j]>0){
short a = in[j];
while(a>0) { //wenn eine Zahl mehrfach vorkam, ward sie a mal ausgegeben
out.append(j+" ");
a--;
}
}
}

count = sc.nextInt();
out.deleteCharAt(out.length()-1); //schneidet das letzte " " von jeder Zeile wieder weg


if(count==0) {
break;
}
else out.append("\n");
}
System.out.println(out); //Ausgabe des Ergebnisses
}
}

2.


/**
* Angewandte Mathematik, SS09, IFB 2C
* ACM Problem #11462 - Age Sort
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=26&problem=2457&mosmsg=Submission+received+with+ID+7205397
*
* @author Hidir Sayli
* @author Taskin Umut
*
* Status : Accepted
* Runtime: 2.208
*/

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.StringTokenizer;

public class Main {

public static void main(String[] args) throws NumberFormatException, IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n=Integer.parseInt(br.readLine());
StringBuilder sb=new StringBuilder();
while(n!=0)
{
List<Integer> al=new ArrayList<Integer>();
StringTokenizer st=new StringTokenizer(br.readLine());
for(int i=0;i<n;i++)
al.add(Integer.parseInt(st.nextToken()));
Collections.sort(al);
for(int i:al)
sb.append(i+" ");
sb.delete(sb.length()-1, sb.length());
sb.append("\n");
n=Integer.parseInt(br.readLine());
}
sb.delete(sb.length()-1, sb.length());
System.out.println(sb);
}

}