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. char[] input;
  13. input = new char[7];
  14.  
  15. input[0] = 'c';
  16. input[1] = 'a';
  17. input[2] = 'x';
  18. input[3] = 'b';
  19. input[4] = 'd';
  20. input[5] = 'y';
  21. input[6] = 'g';
  22.  
  23. int length = input.length;
  24.  
  25. char letter;
  26. int i = 0;
  27. int j = 1;
  28. int printJ = 0;
  29.  
  30. while (i < length) {
  31. while (j < length) {
  32. if (input[j] < input[j - 1]) {
  33. letter = input[j];
  34. input[j] = input[j-1];
  35. input[j-1] = letter;
  36. }
  37. j++;
  38. }
  39. i++;
  40. j = i;
  41. }
  42.  
  43. while (printJ < length) {
  44. System.out.println(input[printJ++]);
  45. }
  46.  
  47. //System.out.println(input[0]);
  48. //System.out.println(input[1]);
  49. //System.out.println(input[2]);
  50. //System.out.println(input[3]);
  51. }
  52. }
Success #stdin #stdout 0.09s 320256KB
stdin
Standard input is empty
stdout
a
b
c
d
g
x
y