fork(8) 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 relationIs = 0;
  13. int resultLength = 4;
  14. String baseInput = "flames";
  15. String temp = "";
  16. if (resultLength > 0) {
  17. while (baseInput.length() !=1)
  18. {
  19. System.out.println(baseInput);
  20. int tmpLen = resultLength % baseInput.length(); //finding char position to strike
  21. if(tmpLen != 0)
  22. {
  23. temp = baseInput.substring(tmpLen) + baseInput.substring(0, tmpLen-1); //Append part start from next char to strike and first charater to char before strike.
  24. }
  25. else
  26. {
  27. temp = baseInput.substring(0, baseInput.length()-1);
  28. }
  29. baseInput = temp; //Assign the temp to baseinput for next iteration.
  30. }
  31. relationIs = baseInput.charAt(0);
  32. System.out.println(relationIs);
  33. }
  34. }
  35. }
Success #stdin #stdout 0.07s 380160KB
stdin
Standard input is empty
stdout
flames
esfla
aesf
aes
es
e