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, 
0sizeof
(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;
}