给一组字符窜,一行n个,按下面形式书写,按列打
t o i o y
h p k n n
e l e a i
r a h s g
e c o n h
s e m o t
n l e w x
Sample Input
5
toioynnkpheleaigshareconhtomesnlewx
3
ttyohhieneesiaabss
0
Sample Output
theresnoplacelikehomeonasnowynightx
thisistheeasyoneab
#include <stdio.h>
#include<string.h>
int main(int argc, char *argv[])
{
int i,j,n;
char ch[30][300],ch1[9000];
while(scanf("%d",&n) && n)
{
scanf("%s",ch1);
int len=strlen(ch1);
int t=len/n;
int cas=0;
for (i=0;i<t;i++)
{
if((i+1)%2!=0)//储存
{
for (j=0;j<n;j++)
ch[i][j]=ch1[cas++];
}
else
{
for (j=n-1;j>=0;j--)
ch[i][j]=ch1[cas++];
}
}
for (i=0;i<n;i++)//按列打
for (j=0;j<t;j++)
printf("%c",ch[j][i]);
printf("\n");
}
return 0;
}