10383 - draw a picture   

Description

 Let’s draw a picture on a 15*20 board which is initially plotted a symbol ’-’ at each location. We consider only three patterns as follows:   

You will be given a symbol (cross (x), intersection (+) or square (s)) representing the desired pattern, the radius or side of the pattern, and the assigned coordinate of the pattern’s center point.

 

There are some points that you should know.

1.      You should check if the pattern you draw crosses the boundary of the board. The part which is beyond the board should be ignored.

For example:

2.      If a later pattern overlaps an existing pattern, the later pattern will replace the existing one within the overlapping area.

For example:

3.      For a square pattern, you will be given only an odd number as its side.

You may use the following piece of code:

#include #include 
#define LENGTH 15
#define WIDTH 20

void cross(int r, int x, int y);
void intersection(int r, int x, int y);
void square(int r, int x, int y);
void printboard();

char board[LENGTH][WIDTH];
int i,j;

int main(){

    char symbol;
    int radius,row,col;

    for(i=0;i
  

Input

The input contains several lines. Each line contains one symbol and three numbers. The first symbol represents the pattern you should draw. The second number represents the radius of the pattern. The third and fourth numbers represent the coordinate of the pattern’s center point.

An input line containing only ’e’ represents the end of the input.

Output

The output should print the 15*20 board.

Sample Input  Download

Sample Output  Download

Tags




Discuss