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="",input;
  7. int Y=0,c,i=0,columns,length;
  8. Character temp;
  9. for(;5==5;Y=0,result=""){
  10. columns = Integer.parseInt(read.readLine());
  11. if(columns == 0){
  12. break;
  13. }
  14. input = read.readLine();
  15. 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. }
  22. i++;
  23. if(i>=(length/columns)){
  24. break;
  25. }
  26. for(c=columns-1;c>=0;c--,Y++){
  27. temp = input.charAt(Y);
  28. A[c][i] = temp.toString();
  29. }
  30. }
  31.  
  32. for(i=0;i<columns;i++){
  33. for(c=0;c<(length/columns);c++){
  34. result = result + A[i][c];
  35. }
  36. }
  37. System.out.println(result);
  38. }
  39. }
  40. }
Success #stdin #stdout 0.08s 212416KB
stdin
5
toioynnkpheleaigshareconhtomesnlewx
3
ttyohhieneesiaabss
0
stdout
theresnoplacelikehomeonasnowynightx
thisistheeasyoneab