您的位置:首页 > 其它

杭电2052-Picture

2016-06-15 13:53 495 查看
[align=left]Problem Description[/align]
Give you the width and height of the rectangle,darw it.
 

[align=left]Input[/align]
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.
 

[align=left]Output[/align]
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.
 

[align=left]Sample Input[/align]

3 2

 

[align=left]Sample Output[/align]

+---+
| |
| |
+---+

AC代码如下:
#include "stdio.h"

int main(int
argc, char* argv[])
{
int
n,m;
int
i,j;
while (
scanf("%d%d",&n,&m)!=EOF)
{
for (
i=1;i<=m+2;i++)
{
for(
j=1;j<=n+2;j++)
{
if ((
i==1&&j==1)||(i==1&&j==n+2)||(i==m+2&&j==1)||(i==m+2&&j==n+2))
{

printf("+");
}
else if ((
i==1||i==m+2)&&j!=1&&j!=n+2)
{

printf("-");
}
else if ((
j==1||j==n+2)&&i!=1&&i!=m+2)
{

printf("|");
}
else
{

printf(" ");
}
}

printf("\n");
}

printf("\n");
}
return
0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: