X and paintings Gym - 101028D

版权声明:文章全是安利转载啦,自娱自乐喽, 可以随意操作哟! https://blog.csdn.net/ggqinglfu/article/details/82192701

 X and paintings

 Gym - 101028D

Statements

X is well known artist, no one knows the secrete behind the beautiful paintings of X except his friend Y, well the reason that Y knows X's secrete is that he is that secret. Y is a programmer and he helps X with drawing paintings using computer program written by him. Unfortunately Y program is not working any more, now it's your turn to help X by writing a program that helps him in painting, your program should accept a sequence of instructions, each will draw an opaque (filled) rectangle in the form: r1, c1, r2, c2, color. where (r1, c1) is the upper left corner of the rectangle and (r2, c2) is the lower right corner, and color is a character that denotes the color of this rectangle. all rectangles will be printed on a R by Cplane, by default this plane is filled with dots (i.e. '.'). R and C between 1 and 100. for each instruction (1 ≤ ri ≤ R) and (1 ≤ ci ≤ C) and color is a ASCII character [a-z]. The number of instructions won't exceed 100 instructions.

 Input

The first line of input contains an integer T denotes number of test cases. The first line of each test case contains three integers RC ,I where R and C denotes number of rows and columns of the painting, and I denotes number of instructions. Each of the next I lines contains four integers r1,c1,r2,c2 and the color character.

 Output

Print the final plane after evaluating the instructions in order.

 Example

Input

1
5 5 3
1 1 2 2 a
1 2 5 5 c
2 2 3 3 d

Output

acccc
addcc
.ddcc
.cccc
.cccc

 好喜欢这个点阵输出的提亚马特!
就喜欢这么方的 阵!
上 代码 (代码来自社会我浩哥)jie lian 这里有链接

tip:

1、今天 队友做题, 把s【】【】开成100 100 了, 就rte了, 

2、 memset(s, '\0', sizeof(s));  以后也习惯去用 memset 字符串初四花为 ‘\0’;

3、先是点阵, 再依次更新图阵, 虽然实为水题, 但是很喜欢 游戏四哈。

4、这个题 哈哈哈 内心wa 了无数遍了 

#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cstdio>
#define INF 0x3f3f3f3f
using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    int t;
    cin >> t;
    char s[105][105], s1;
    while(t--)
    {
        int r, c, i;
        cin >> r >> c >> i;
        memset(s, '\0', sizeof(s));
        for(int j = 1; j <= r; j++)
        {
            for(int k = 1; k <= c; k++)
            {
                s[j][k] = '.';
            }
        }
        int r1, c1, r2, c2;
        while(i--)
        {
            cin >> r1 >> c1 >> r2 >> c2 >> s1;
            for(int j = r1; j <= r2; j++)
            {
                for(int k = c1; k <= c2; k++)
                {
                    s[j][k] = s1;
                }
            }
        }
        for(int j = 1; j <= r; j++)
        {
            for(int k = 1; k <= c; k++)
            {
                cout << s[j][k];
            }
            cout << endl;
        }
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/ggqinglfu/article/details/82192701