Code: Select all
#include<stdio.h>
int main()
{
int i,j,k,r,c,end;
char arr[409],st[21][21];
while(scanf("%d %d",&r,&c)==2&&r!=0&&c!=0)
{
getchar();
gets(arr);
k=0;
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
st[i][j]=arr[k];
k++;
}
}
k=0;
if(c%2==0)
end=c/2-1;
else
end=c/2;
while(k<=end)
{
for(i=k;i<c-k;i++)
printf("%c",st[k][i]-7);
for(i=k+1;i<r-k;i++)
printf("%c",st[i][c-(k+1)]-7);
for(i=c-(k+2);i>=k;i--)
printf("%c",st[r-(k+1)][i]-7);
for(i=r-(k+2);i>k;i--)
printf("%c",st[i][k]-7);
k++;
}
puts("");
}
return 0;
}