Created
April 19, 2018 01:27
-
-
Save ioxua/6e15776e7e4fd5b3a14b7933c086ddad 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 class Principal { | |
public static void main(String[] args) { | |
int[] vetor = new int[]{ 2, 7, 1, 12, 6, 4, 3, 5, 123, 0, -1, -123 }; | |
boolean flg = true; | |
do{ | |
int troca = 0; | |
flg = false; | |
for(int i = 0;i < vetor.length - 1; i++){ | |
if (vetor[i] >= vetor[i+1]) | |
{ | |
troca = vetor[i+1]; | |
vetor[i+1] = vetor[i]; | |
vetor[i] = troca; | |
flg = true; | |
} | |
} | |
} while (flg = true); | |
System.out.print("["); | |
for(int i = 0; i < vetor.length; i++) { | |
System.out.print(vetor[i]); | |
if(i + 1 < vetor.length) | |
System.out.print(", "); | |
} | |
System.out.println("]"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment