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[])
  11. {
  12. int t[] = {3, 5, 2}; // your reading part is fine, so I will skip it
  13. sortArrayWithoutCheating(t);
  14. System.out.println(Arrays.toString(t));
  15. }
  16.  
  17. public static void sortArrayWithoutCheating(int[] t)
  18. {
  19. for (int i = 0; i < t.length; i++)
  20. {
  21. for (int j = 0; j < i; j++)
  22. {
  23. if (t[i] < t[j])
  24. {
  25. // swap t[i] and t[j]
  26. int temp = t[i];
  27. t[i] = t[j];
  28. t[j] = temp;
  29. }
  30. }
  31. }
  32. }
  33. }
Success #stdin #stdout 0.07s 380160KB
stdin
Standard input is empty
stdout
[2, 3, 5]