Created
September 12, 2018 07:10
-
-
Save rafaduka/1073742080e3ece416aea66d87ad20f6 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
public static void main(String args[]){ | |
int[] vet = {8, 9, 3, 5, 1}; | |
int aux = 0; | |
int i = 0; | |
System.out.println("Vetor desordenado: "); | |
for(i = 0; i<5; i++){ | |
System.out.println(" "+vet[i]); | |
} | |
System.out.println(" "); | |
for(i = 0; i<5; i++){ | |
for(int j = 0; j<4; j++){ | |
if(vet[j] > vet[j + 1]){ | |
aux = vet[j]; | |
vet[j] = vet[j+1]; | |
vet[j+1] = aux; | |
} | |
} | |
} | |
System.out.println("Vetor organizado:"); | |
for(i = 0; i<5; i++){ | |
System.out.println(" "+vet[i]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment