1.6 [hduoj] 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

+---+

|      |

|      |

+---+

#include<stdio.h>
void main()
{
    int m,n;        //m列n行
    while(scanf("%d%d",&m,&n)!=EOF)
    {
        char a[75][75];
        a[0][0]=a[0][m+1]='+';
        a[n+1][0]=a[n+1][m+1]='+';
        for(int i=1;i<=m;i++)
            a[0][i]=a[n+1][i]='-';
        for(int i=1;i<=n;i++)
            a[i][0]=a[i][m+1]='|';
        for(int i=1;i<=n;i++)
            for(int j=1;j<=m;j++)
                a[i][j]=' ';
        for(int i=0;i<=n+1;i++)
        {
            for(int j=0;j<=m+1;j++)
            {
                if(j==m+1)
                    printf("%c\n",a[i][j]);
                else
                    printf("%c",a[i][j]);
            }
        }
        printf("\n");
    }
}
发布了153 篇原创文章 · 获赞 4 · 访问量 3720

猜你喜欢

转载自blog.csdn.net/qq_39782006/article/details/103843785
1.6
今日推荐