hdu 2052 Picture

ACM比赛整理

共 1291字,需浏览 3分钟

 ·

2021-07-12 19:52

Picture

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 53460    Accepted Submission(s): 25652


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

+---+
| |
| |
+---+

 


代码:

# include <stdio.h>
# include <string.h>
# define REP(a,b) for(a = 0 ; a < b ; a++)
char gp[100][100] ;
int main ()
{
int i, n, m ;
while (~scanf ("%d%d", &n, &m))
{
memset(gp, ' ', sizeof(gp)) ;
REP(i,m+2)
gp[i][0] = gp[i][n+1] = '|', gp[i][n+2] = '\0' ;
REP(i,n+2)
gp[0][i] = gp[m+1][i] = '-' ;
gp[0][0] = gp[0][n+1] = gp[m+1][0] = gp[m+1][n+1] = '+'
REP(i,m+2)
puts (gp[i]) ;
puts ("") ;
}
return 0 ;
}



浏览 31
点赞
评论
收藏
分享

手机扫一扫分享

举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

举报