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

 

 
posted @ 2013-05-12 10:27  xiaxiaosheng  阅读(148)  评论(0编辑  收藏  举报