zoukankan      html  css  js  c++  java
  • POJ

    POJ - 1132Border

    Time Limit: 1000MS

     

    Memory Limit: 10000KB

     

    64bit IO Format: %I64d & %I64u

     

    Description

    You are to write a program that draws a border around a closed path into a bitmap, as displayed in the following figure: 


    The path is closed and runs along the grid lines, i.e. between the squares of the grid. The path runs counter-clockwise, so if following the path is considered as going ``forward'', the border pixels are always to the "right'' of the path. The bitmap always covers 32 by 32 squares and has its lower left corner at (0, 0). You can safely assume that the path never touches the bounding rectangle of the bitmap and never touches or crosses itself. Note that a bit gets set if it is on the outside of the area surrounded by the path and if at least one of its edges belongs to the path, but not if only one of its corners is in the path. (A look at the convex corners in the figure should clarify that statement.) 

    Input

    The first line of the input file contains the number of test cases in the file. Each test case that follows consists of two lines. The first line of each case contains two integer numbers x and y specifying the starting point of the path. The second line contains a string of variable length. Every letter in the string symbolizes a move of length one along the grid. Only the letters 'W' ("west"), 'E' ("east"), 'N' ("north"), 'S' ("south"), and '.' ("end of path", no move) appear in the string. The end-of-path character ( '.') is immediately followed by the end of the line.

    Output

    For each test case, output a line with the number of the case ('Bitmap #1', 'Bitmap #2', etc.). For each row of the bitmap from top to bottom, print a line where you print a character for every bit in that row from left to right. Print an uppercase 'X' for set bits and a period '.' for unset bits. Output a blank line after each bitmap.

    Sample Input

    1

    2 1

    EENNWNENWWWSSSES.

    Sample Output

    Bitmap #1

    ................................

    ................................

    ................................

    ................................

    ................................

    ................................

    ................................

    ................................

    ................................

    ................................

    ................................

    ................................

    ................................

    ................................

    ................................

    ................................

    ................................

    ................................

    ................................

    ................................

    ................................

    ................................

    ................................

    ................................

    ................................

    ................................

    .XXX............................

    X...X...........................

    X..X............................

    X...X...........................

    .X..X...........................

    ..XX............................

    Source

    Southwestern European Regional Contest 1996

     1 #include<stdio.h>
     2 #include<string.h>
     3 
     4 bool b[32][32];
     5 
     6 int main()
     7 {
     8     int cnt = 0, x = 0, y = 0;
     9     char c = '';/*, p = ''*/
    10     scanf("%d", &cnt);
    11     for(int i = 0; i < cnt; i++) {
    12         memset(b, 0, sizeof(b));
    13         printf("Bitmap #%d
    ", i+1);
    14         scanf("%d%d", &x, &y);
    15         while(true) {
    16             scanf("%c", &c);
    17             if(c == '.') break;
    18             switch(c){
    19                 case 'E':
    20                     b[x][y-1] = 1;
    21                     x++;
    22                     break;
    23                 case 'N':
    24                     b[x][y] = 1;
    25                     y++;
    26                     break;
    27                 case 'W':
    28                     b[x-1][y] = 1;
    29                     x--;
    30                     break;
    31                 case 'S':
    32                     b[x-1][y-1] = 1;
    33                     y--;
    34             }
    35         }
    36 
    37         for(int k = 31; k >= 0; k--) {
    38             for(int j = 0; j < 32; j++) {
    39                 if(b[j][k]) printf("X");
    40                 else printf(".");
    41             }
    42             printf("
    ");
    43         }
    44         printf("
    ");
    45     }
    46 
    47 
    48     return 0;
    49 }
  • 相关阅读:
    msp430入门编程25
    msp430入门编程24
    msp430入门编程23
    msp430入门编程22
    msp430入门编程21
    msp430入门编程20
    msp430入门编程16
    msp430入门编程15
    msp430入门编程14
    msp430入门编程13
  • 原文地址:https://www.cnblogs.com/acmicky/p/3221415.html
Copyright © 2011-2022 走看看