fork(1) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. int[] vetorOrdenado = new int[8];
  13.  
  14. vetorOrdenado[0] = 2;
  15. vetorOrdenado[1] = 41;
  16. vetorOrdenado[2] = 12;
  17. vetorOrdenado[3] = 6;
  18. vetorOrdenado[4] = 5;
  19. vetorOrdenado[5] = 29;
  20. vetorOrdenado[6] = 17;
  21. vetorOrdenado[7] = 3;
  22.  
  23. for(int i = 0; i < vetorOrdenado.length;i++){
  24. for(int j = 0; j < vetorOrdenado.length - 1; j++){
  25. if(vetorOrdenado[i] < vetorOrdenado[j]){
  26. int aux = vetorOrdenado[i];
  27. vetorOrdenado[i] = vetorOrdenado[j];
  28. vetorOrdenado[j] = aux;
  29. }
  30.  
  31.  
  32. }
  33. }
  34.  
  35. for(int a : vetorOrdenado){
  36. System.out.println(a);
  37. }
  38. }
  39. }
Success #stdin #stdout 0.1s 320576KB
stdin
Standard input is empty
stdout
2
3
5
6
12
17
29
41