HDU 2052 Picture

Posted zlrrrr

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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;
}

  

 


以上是关于HDU 2052 Picture的主要内容,如果未能解决你的问题,请参考以下文章

HDUJ 2052 Picture 模拟

HDU 1162 Eddy's picture (最小生成树)(java版)

Hdu1828 Picture

HDU-1828-Picture(线段树)

hdu 1828 Picture(线段树,扫描线)

题解报告:hdu 1162 Eddy's picture