fork 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. // your code goes here
  13. int []arr = {1,12,23,45,5,5};
  14. int max = Integer.MIN_VALUE;
  15. int tmp =0;
  16. for (int i=0;i<arr.length;i++){
  17. for (int j = i+1;j<arr.length;j++){
  18. if(arr[i] > arr[j]){
  19. tmp = arr[i];
  20. arr[i]=arr[j];
  21. arr[j]=tmp;
  22. }
  23. }
  24. }
  25. for (int i=0;i<arr.length;i++){
  26. System.out.println(arr[i]);
  27. }
  28. }
  29. }
Success #stdin #stdout 0.08s 52644KB
stdin
Standard input is empty
stdout
1
5
5
12
23
45