HDU 2052 Picture

http://acm.hdu.edu.cn/showproblem.php?pid=2052

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 <bits/stdc++.h>

using namespace std;

int a[100][100];
int len;

int main()
{
    int n,m;
    while(cin>>m>>n)
    {
        for(int i=1; i<=n+2; i++)
        {
            if(i==1||i==n+2)
                for(int j=1; j<=m+2; j++)
                {
                    if(j==1)
                        cout<<"+";
                    else if(j==m+2)
                        cout<<"+"<<endl;
                    else
                        cout<<"-";
                }
            else
                for(int j=1; j<=m+2; j++)
                {
                    if(j==1)
                        cout<<"|";
                    else if(j==m+2)
                        cout<<"|"<<endl;
                    else
                        cout<<" ";
                }
        }
        cout<<endl;
    }
    return 0;
}

  

原文地址:https://www.cnblogs.com/zlrrrr/p/9221882.html