题意:<space> = 0, A = 1, B = 2, C = 3, ..., Y = 25, Z = 26 (10进制额度)
给你字符窜,让你输出数字,每个数字代表二进制的五位数,按一定蛇形顺序排列,然后
从首位按顺序输出 比如ACM 输入行列都是4 4

最后输出是000010001101101
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int vis[500][500];
int a[500][500];
int main()
{
char Gra[30][6]={"00000","00001","00010","00011","00100","00101","00110","00111",
"01000","01001","01010","01011","01100","01101","01110","01111",
"10000","10001","10010","10011","10100","10101","10110","10111",
"11000","11001","11010"};
int T,c,r;
char ch1[200];//存储输入的字母
int ch2[500];
int ttt=1;
int i,j;
scanf("%d",&T);
while(T--)
{
memset(vis,0,sizeof(vis));
scanf("%d%d",&r,&c);
getchar();
gets(ch1);
int len=strlen(ch1);
int cas=0;
//将acm这样的值变化成数字赋予ch2
for (i=0;i<len;i++)//ch1的长度
for (j=0;j<5;j++)
{
if(ch1[i]==' ') ch2[cas++]=Gra[0][j]-'0';
else ch2[cas++]=Gra[ch1[i]-'A'+1][j]-'0';
}
//将未填满的位置填充0
for (int k=len*5;k<r*c;k++)
ch2[cas++]=0;
int t=1;
int x=0,y=0;//控制位置
len=r*c;
a[0][0]=ch2[0];
vis[0][0]=1;
while(t<len)
{
while( y+1<c && !vis[x][y+1])
{
vis[x][++y]=1;
a[x][y]=ch2[t++];//右
}
while( x+1<r && !vis[x+1][y])
{
vis[++x][y]=1;
a[x][y]=ch2[t++];//下
}
while( y-1>=0 && !vis[x][y-1])
{
vis[x][--y]=1;
a[x][y]=ch2[t++];//左
}
while( x-1>=0 && !vis[x-1][y])
{
vis[--x][y]=1;
a[x][y]=ch2[t++];//上
}
}
printf("%d ",ttt++);
for (i=0;i<r;i++)
for (j=0;j<c;j++)
printf("%d",a[i][j]);
printf("\n");
}
return 0;
}