#include <stdio.h>
int main()
{
char puzzle[12][12];
int r, c, i, ct = 0;
while(1 == scanf("%d", &r) && r && 1 == scanf("%d", &c))
{
while(getchar() != '\n');
for(i = 0; i < r; ++i)
gets(puzzle[i]);
if(ct) putchar('\n');
printf("puzzle #%d:\n", ++ct);
printf("Across\n");
int x, y, num = 0;
for(x = 0; x < r; ++x)
{
for(y = 0; y < c; ++y)
{
if((puzzle[x][y] != '*') && (y - 1 < 0 || x - 1 < 0 || puzzle[x][y-1] == '*' || puzzle[x-1][y] == '*'))
++num;
if(puzzle[x][y] != '*' && (y - 1 < 0 || puzzle[x][y-1] == '*'))
{
printf("%3d.", num);
int t = y;
while(t < c && puzzle[x][t] != '*')
putchar(puzzle[x][t++]);
putchar('\n');
}
}
}
num = 0; printf("Down\n");
for(x = 0; x < r; ++x)
{
for(y = 0; y < c; ++y)
{
if((puzzle[x][y] != '*') && (y - 1 < 0 || x - 1 < 0 || puzzle[x][y-1] == '*' || puzzle[x-1][y] == '*'))
++num;
if(puzzle[x][y] != '*' && (x - 1 < 0 || puzzle[x-1][y] == '*'))
{
printf("%3d.", num);
int t = x;
while(t < r && puzzle[t][y] != '*')
putchar(puzzle[t++][y]);
putchar('\n');
}
}
}
}
return 0;
}
UVa 232:Crossword Answers
最新推荐文章于 2023-11-28 14:47:24 发布