简单题
View Code
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
#define maxn 40
int x, y;
bool map[maxn][maxn];
char st[maxn * maxn * 2];
void input()
{
scanf("%d%d", &x, &y);
scanf("%s", st);
int n = strlen(st);
memset(map, 0, sizeof(map));
for (int i = 0; i < n - 1; i++)
{
if (st[i] == 'E')
{
map[x][y - 1] = true;
x++;
}else if (st[i] == 'N')
{
map[x][y] = true;
y++;
}else if (st[i] == 'W')
{
map[x - 1][y] = true;
x--;
}else
{
map[x - 1][y - 1] = true;
y--;
}
}
}
void print()
{
for (int i = 31; i >= 0; i--)
{
for (int j = 0; j < 32; j++)
if (map[j][i])
printf("X");
else
printf(".");
putchar('\n');
}
}
int main()
{
//freopen("t.txt", "r", stdin);
int t;
scanf("%d", &t);
for (int i = 0; i < t; i++)
{
printf("Bitmap #%d\n", i + 1);
input();
print();
putchar('\n');
}
return 0;
}