/**
** Author: Walid Bahsow.
** E-mail: wabsnet@yahoo.com
** Friday 21th of March, 2003
**/
/* This is a program which reads an N number of elements from a file (where N
is the first
* number in the file), and sorts them using the java built in sort method and then
* prints them on another file.
*/
import java.io.*;
import java.util.*;
class NumSort {
static StreamTokenizer in;
static PrintWriter out;
static int[] list;
static int N;
public static void main(String[] args)throws IOException {
init();
Arrays.sort(list); //sorts the list
printer();
} // end main
// Reads in the numbers and puts them in the array list.
static void init()throws IOException {
in = new StreamTokenizer(new
FileReader("numsort.in"));
in.nextToken();
N = (int)in.nval;
list = new int[N];
in.nextToken();
for (int i = 0; i < list.length; i++)
{
list[i] = (int)
in.nval;
in.nextToken();
}
}
// Prints the array in the file.
static void printer() throws IOException {
out = new PrintWriter (new FileWriter
("numsort.out"));
for (int i = 0; i < list.length; i++)
{
out.println(list[i]);
}
out.close();
}
} // End class NumSort