import java.util.Scanner; public class Zadanie { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("Podaj liczbe elementow do posortowania: "); int liczbaElementow = Integer.parseInt(sc.nextLine()); int[] dane = new int[liczbaElementow]; for (int i = 0; i < liczbaElementow; i++) { dane[i] = Integer.parseInt(sc.nextLine()); } for (int i = 0; i < liczbaElementow - 1; i++) { int indexMin = i; for (int j = i + 1; j < liczbaElementow; j++) { if(dane[indexMin] > dane[j]){ indexMin = j; } } //SWAP int temp = dane[i]; dane[i] = dane[indexMin]; dane[indexMin] = temp; } for (int i = 0; i < liczbaElementow; i++) { System.out.print(dane[i] + " "); } } }