题目:
Problem 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 +---+ | | | | +---+ Author xhd Source 校庆杯Warm Up Recommend linle
代码:
#include <stdio.h> void horizontal(unsigned int); void space(unsigned int); int main(void) { unsigned int n, m, i; while (scanf("%u %u", &n, &m) != EOF) { printf("+"); horizontal(n); printf("+ "); for (i = 0; i < m; ++i) { printf("|"); space(n); printf("| "); } printf("+"); horizontal(n); printf("+ "); } return 0; } void horizontal(unsigned int n) { for (unsigned int i = 0; i < n; ++i) { printf("-"); } } void space(unsigned int n) { for (unsigned int i = 1; i <= n; ++i) { printf(" "); } }