problem 1300
来源:互联网 发布:百度知道和知乎的异同 编辑:程序博客网 时间:2024/06/03 02:13
看了许久才把题意搞懂。 Accepted 1300 C++ 00:00.00 388K
#include<stdio.h>
#include<string.h>
void solve(int x, int y)
{
char c, bmp[32][32], pre;
memset(bmp, 0, sizeof(bmp));
while(scanf("%c", &c) != EOF && c != '.')
{
int x1, y1;
switch(c)
{
case 'E':
x1 = x++, y1 = y - 1;
break;
case 'N':
x1 = x, y1 = y++;
break;
case 'S':
x1 = x - 1, y1 = y-- - 1;
break;
case 'W':
x1 = x-- - 1, y1 = y;
break;
}
bmp[x1][y1] = 1;
}
for(int i = 31; i >= 0; i--, printf(" "))
for(int j = 0; j < 32; j++)
(bmp[j][i] == 1) ? printf("X") : printf(".");
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("1300.txt", "r", stdin);
#endif
int t, x, y;
while(scanf("%d", &t) != EOF)
for(int i = 0; i < t; i++)
{
scanf("%d%d ", &x, &y);
printf("Bitmap #%d/n", i + 1);
solve(x, y);
printf("/n");
}
#ifndef ONLINE_JUDGE
fclose(stdin);
#endif
return 0;
}
#include<string.h>
void solve(int x, int y)
{
char c, bmp[32][32], pre;
memset(bmp, 0, sizeof(bmp));
while(scanf("%c", &c) != EOF && c != '.')
{
int x1, y1;
switch(c)
{
case 'E':
x1 = x++, y1 = y - 1;
break;
case 'N':
x1 = x, y1 = y++;
break;
case 'S':
x1 = x - 1, y1 = y-- - 1;
break;
case 'W':
x1 = x-- - 1, y1 = y;
break;
}
bmp[x1][y1] = 1;
}
for(int i = 31; i >= 0; i--, printf(" "))
for(int j = 0; j < 32; j++)
(bmp[j][i] == 1) ? printf("X") : printf(".");
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("1300.txt", "r", stdin);
#endif
int t, x, y;
while(scanf("%d", &t) != EOF)
for(int i = 0; i < t; i++)
{
scanf("%d%d ", &x, &y);
printf("Bitmap #%d/n", i + 1);
solve(x, y);
printf("/n");
}
#ifndef ONLINE_JUDGE
fclose(stdin);
#endif
return 0;
}
- problem 1300
- CDOJ 1300 Easy Problem
- problem
- Problem
- problem
- Problem
- Problem
- Problem
- Problem
- Problem
- Problem
- problem
- Problem
- Problem
- Problem
- Problem
- Problem
- Problem
- 缓慢行走的青春
- SQLServer技术(129)
- 浏览器自动关闭怎么办
- 黄仁勋:华人成就经典美国梦
- SQLServer技术(73)
- problem 1300
- SQLServer技术(74)
- 关于男人的一些方面
- NVIDIA黄仁勋:互联网领域30岁创业恐太老
- SQLServer技术(75)
- SQLServer技术(76)
- SQLServer技术(77)
- 要做这样的女孩
- SQLServer技术(78)