题目
Picture
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 47081 Accepted Submission(s): 22735
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
±–+
| |
| |
±–+
解题
这是一题水题,别问我为什么水题也发,问就是204多的递推专题系列,一题都做不出来,我傻了
AC代码
#include <iostream>
using namespace std;
int main() {
int w,h;
while (scanf("%d%d", &w,&h) != EOF) {
printf("+");
for (int i = 0; i < w; i++) {
printf("-");
}
printf("+\n");
//打完首行
for (int i = 0; i < h; i++) {
printf("|");
for (int j = 0; j < w; j++) {
printf(" ");
}
printf("|\n");
}
//打完中间
printf("+");
for (int i = 0; i < w; i++) {
printf("-");
}
printf("+\n\n");
}
return 0;
}