-
-
Save uncoded-ro/1ca2e7753c24c620d554a14f9c2dbf9a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Sortare { | |
public static void sortare(int[] numere) { | |
for (int i = 0; i < numere.length; i++) { | |
int min = i; | |
for (int j = i; j < numere.length; j++) { | |
if (numere[j] < numere[min]) | |
min = j; | |
} | |
int temp; | |
temp = numere[i]; | |
numere[i] = numere[min]; | |
numere[min] = temp; | |
} | |
} | |
public static void main(String[] args) { | |
int[] numere = new int[10]; | |
for (int i = 0; i < numere.length; i++) { | |
numere[i] = (int) (Math.random() * 100); | |
} | |
System.out.println("Afisare elemente tablou inainte de sortare"); | |
for (int i = 0; i < numere.length; i++) { | |
System.out.print(numere[i] + " "); | |
} | |
sortare(numere); | |
System.out.println(); | |
System.out.println("Afisare elemente tablou dupa sortare"); | |
for (int i = 0; i < numere.length; i++) { | |
System.out.print(numere[i] + " "); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment