Skip to content

Instantly share code, notes, and snippets.

@ioxua
Created April 19, 2018 01:27
Show Gist options
  • Save ioxua/6e15776e7e4fd5b3a14b7933c086ddad to your computer and use it in GitHub Desktop.
Save ioxua/6e15776e7e4fd5b3a14b7933c086ddad to your computer and use it in GitHub Desktop.
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