fork download
  1. import java.io.*;
  2. public class Main {
  3. public static void main (String[]args)throws Exception{
  4.  
  5. String[] []A = new String [20][100];
  6. String result="";
  7. int Y=0,c,i=0;
  8. Character temp;
  9. for(;5==5;Y=0,result=""){
  10. int columns = Integer.parseInt(read.readLine());
  11. if(columns == 0){
  12. break;
  13. }
  14. String input = read.readLine();
  15. int length = input.length();
  16.  
  17. for(i=0;i<(length/columns);i++){
  18. for(c=0;c<columns;c++,Y++){
  19. temp = input.charAt(Y);
  20. A[c][i] = temp.toString();
  21. // System.out.println(A[c][i]);
  22. }
  23.  
  24. i++;
  25. if(i>=(length/columns)){
  26. break;
  27. }
  28. for(c=columns-1;c>=0;c--,Y++){
  29. temp = input.charAt(Y);
  30. A[c][i] = temp.toString();
  31. // System.out.println(A[c][i]);
  32.  
  33. }
  34. }
  35.  
  36. for(i=0;i<columns;i++){
  37. for(c=0;c<(length/columns);c++){
  38. result = result + A[i][c];
  39. }
  40. }
  41. System.out.println(result);
  42. }
  43. }
  44. }
Success #stdin #stdout 0.09s 212416KB
stdin
5
toioynnkpheleaigshareconhtomesnlewx
3
ttyohhieneesiaabss
0
stdout
theresnoplacelikehomeonasnowynightx
thisistheeasyoneab