fork download
  1. public class Main {
  2. public static void main(final String[] args) {
  3. String str = "helloworldnewday";
  4. double length = Math.sqrt(str.length());
  5. int x = (int) length;
  6. for (int i = 0, len = str.length(); i < len; i++) {
  7. System.out.print(str.charAt(i) + " ");
  8. if (i % x == x - 1) {
  9. System.out.println();
  10. }
  11. }
  12. }
  13. }
Success #stdin #stdout 0.08s 33976KB
stdin
Standard input is empty
stdout
h e l l 
o w o r 
l d n e 
w d a y