hdu 2052.picture 题解 代码

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

+—+
| |
| |
+—+

题解

水题,照着规律输出就行

代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include<stdio.h>
int main()
{
int width,heigh;
while(scanf("%d %d",&width,&heigh)!=EOF)
{
for(int i=1;i<=heigh+2;i++)
{
for(int j=1;j<=width+2;j++)
{
if((i==1&&j==1)||(i==1&&j==width+2)||(i==heigh+2&&j==1)||(i==heigh+2&&j==width+2)) printf("+");
else if((i==1||i==heigh+2)&&(j!=1&&j!=width+2)) printf("-");
else if((i!=1||i!=heigh+2)&&(j==1||j==width+2)) printf("|");
else printf(" ");
}
printf("n");
}
printf("n");
}
return 0;
}