【链接】 我是链接,点我呀:)
【题意】
【题解】
模拟题。注意场宽为3【代码】
#include <bits/stdc++.h>
using namespace std;
const int N = 10;
int n, m, num[N + 10][N + 10], last[N + 10];
string s[N + 10];
int main()
{
/*freopen("F:\rush.txt", "r", stdin);*/
int kk = 0;
while (cin >> n && n)
{
if (kk) puts("");
memset(last, 0, sizeof last);
cin >> m;
for (int i = 0; i < n; i++) cin >> s[i];
int cnt = 0;
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
if (s[i][j]!='*' && (j == 0 || i == 0 || s[i][j - 1] == '*' || s[i - 1][j] == '*'))
num[i][j] = ++cnt;
printf("puzzle #%d:
", ++kk);
printf("Across
");
for (int i = 0; i < n; i++)
{
int now = 0;
for (int j = now; j < m; j++)
if (j >= now && isalpha(s[i][j]) && (j == 0 || s[i][j - 1] == '*'))
{
printf("%3d.", num[i][j]);
while (j < m && isalpha(s[i][j]))
putchar(s[i][j++]);
puts("");
now = j;
}
}
printf("Down
");
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
if (isalpha(s[i][j]) && (i == 0 || s[i - 1][j] == '*') && i >= last[j])
{
printf("%3d.", num[i][j]);
int now = i;
while (now < n && s[now][j] != '*') putchar(s[now++][j]);
last[j] = now;
puts("");
}
}
}
return 0;
}