fork(10) 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[] vet = { 7, 4, 10, 8, 2, 5 };
  13.  
  14. System.out.println("Array sem ordenacao:");
  15.  
  16. for (int n : vet) {
  17. System.out.print(n + " ");
  18. }
  19. System.out.println();
  20.  
  21. for (int i = 1; i < vet.length; i++) {
  22. for (int j = 0; j < i; j++) {
  23. if (vet[i] > vet[j]) {
  24. int aux = vet[i];
  25. vet[i] = vet[j];
  26. vet[j] = aux;
  27. }
  28.  
  29. }
  30. }
  31.  
  32. System.out.println("Array em ordem decrescente:");
  33.  
  34. for (int n : vet) {
  35. System.out.print(n + " ");
  36. }
  37. System.out.println();
  38. }
  39. }
Success #stdin #stdout 0.05s 4386816KB
stdin
Standard input is empty
stdout
Array sem ordenacao:
7 4 10 8 2 5 
Array em ordem decrescente:
10 8 7 5 4 2