
import java.util.Random;

/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template
 */

/**
 *
 * @author mateo
 */
public class Sortowanie {

    /**
     * @param args the command line arguments
     */
    public static void sortuj(int[] tab) {
        for(int i=0; i<tab.length - 1; i++) {
            for(int j=0; j<tab.length-i-1; j++) {
                if(tab[j] > tab[j+1]) {
                    int temp = tab[j];
                    tab[j] = tab[j+1];
                    tab[j+1] = temp;
                }
            }
        }
    }
    
    public static int[] wypelnijTablice() {
        int[] tab = new int[100];
        
        Random rand = new Random();
        
        for(int i=0; i<100; i++) {
            tab[i] = rand.nextInt(0, 1000);
        }
        
        return tab;
    }
    
    public static void wyswietlTablice(int[] tab) {
        for(int i=0; i<tab.length; i++) {
            System.out.print(tab[i] + " ");
        }
        System.out.print('\n');
    }
    
    public static void main(String[] args) {
        // TODO code application logic here
        int[] tab = wypelnijTablice();
        
        System.out.println("Tablica przed sortowaniem:");
        wyswietlTablice(tab);
        
        sortuj(tab);
       
        System.out.println("Tablica po sortowaniu:");
        wyswietlTablice(tab);
    }
    
}
