/* Zadanie: Sortowanie tablicy 1000 elementowej */

public class start {
  public static void main(String[] args) {
    int [] tablica = new int [1000];
    int lp1,lp2;
    System.out.println("Wypelnienie tablicy 1000-elem. liczbami pseudolosowymi...");
    for (lp1 = 1;lp1 < tablica.length; lp1++ ) {
      tablica [lp1] = (int)(Math.random()*2000);
      System.out.print(tablica[lp1]+",");
      if ((lp1%15)==0) System.out.println();
// wyswietlanie po 15 wartosci w lini
    }
    System.out.println(); System.out.println();
    System.out.println("Sortuje (pomijajac komórki juz posortowane)...");
    int temp = 0;
    for (lp1 = 1; lp1 < tablica.length; lp1++) {
    for (lp2 = lp1; lp2 < tablica.length; lp2++) {
      if (tablica[lp2] < tablica[lp1]) {
        temp = tablica[lp2];
        tablica[lp2] = tablica[lp1];
        tablica[lp1] = temp;
      }
    }
    }
    for (lp1 = 1; lp1 < tablica.length; lp1++) {
      System.out.print(tablica[lp1]+",");
      if ((lp1%15)==0) System.out.println();
    }
  }
}