您的位置:首页 > 编程语言

杭电2052简单代码

2015-12-26 18:39 483 查看
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>

main()

{

    int x,y;

    while(scanf("%d %d",&x,&y)!=EOF)

    {

        int i,j;

        printf("+");

        for(i=1;i<=x;i++)

            printf("-");

        printf("+");

        for(j=1;j<=y;j++)

        {

            printf("\n");

            printf("|");

            for(i=1;i<=x;i++)

            printf(" ");

            printf("|");

        }

        printf("\n");

        printf("+");

         for(i=1;i<=x;i++)

            printf("-");

        printf("+");

        printf("\n");

        printf("\n");

    }

    return 0;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  杭电 杭电oj acm