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

HDoj 2052 Picture

时间:2020-04-11 23:29:43      阅读:97      评论:0      收藏:0      [点我收藏+]

标签:ref   acm   ane   similar   show   The   out   NPU   key   

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
+---+ | | | | +---+
 

 

Author
xhd
 

 

Source
 

 

Recommend
linle   |   We have carefully selected several similar problems for you:  2054 2072 2053 2055 2056 
 
 
 
C语言代码如下:
#include<stdio.h>
int main()
{
    int x,y;
    while(scanf("%d%d",&x,&y)!=EOF)
    {
        x+=2;
        y+=2;

        for(int i=0;i<y;i++)
        {
            for(int j=0;j<x;j++)
            {
                if((i==0&&j==0) ||(i==0&&j==x-1)||(i==y-1&&j==0)||(i==y-1&&j==x-1))
                    printf("+");
                else if(i==0||i==y-1)
                    printf("-");
                else if(j==0||j==x-1)
                    printf("|");
                else
                    printf(" ");
            }
            printf("\n");
        }
        printf("\n");
    }
}

 

HDoj 2052 Picture

标签:ref   acm   ane   similar   show   The   out   NPU   key   

原文地址:https://www.cnblogs.com/wzmm/p/12683032.html

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