HDU - 2052 Picture

Description

Give you the width and height of the rectangle,darw it.

Input

Input contains a number of test cases.For each case ,there are two numbers n and m (0 < n,m < 75)indicate the width and height of the rectangle.Iuput ends of EOF.

Output

For each case,you should draw a rectangle with the width and height giving in the input.
after each case, you should a blank line.

Sample Input

3 2

Sample Output

+---+
|   |
|   |
+---+
#include <iostream>
#include <cstdio>

using namespace std;

int main() {
    int n, m;
    while (scanf("%d %d", &n, &m) != EOF) {
        printf("+");
        for (int i = 0; i < n; i++)
            printf("-");
        printf("+\n");

        for (int i = 0; i < m; i++) {
            printf("|");
            for (int j = 0; j < n; j++)
                printf(" ");
            printf("|\n");
        }

        printf("+");
        for (int i = 0; i < n; i++)
            printf("-");
        printf("+\n\n");
    }
    return 0;
}
发布了329 篇原创文章 · 获赞 342 · 访问量 17万+

猜你喜欢

转载自blog.csdn.net/Aibiabcheng/article/details/105336730