码迷,mamicode.com
首页 > 其他好文 > 详细

HDU 2052 Picture

时间:2018-06-24 22:25:40      阅读:157      评论:0      收藏:0      [点我收藏+]

标签:put   with   end   std   tput   input   script   space   draw   

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

标签:put   with   end   std   tput   input   script   space   draw   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!