【Picture】Give you the width and height of the rectangle, draw 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>
int main()
{
int width = 0;
int height = 0;
while (scanf("%d%d", &width, &height) != EOF && width > 0 && height < 75)
{
for (int j = 0; j < height + 2; j++)
{
for (int i = 0; i < width + 2; i++)
{
if (j == 0 || j == height + 1)
{
//把框架摆好
//+---+
//+---+
if (i == 0 || i == width + 1)
printf("+");
else
printf("-");
}
//“见缝插针”
else if (i == 0 || i == width + 1)
printf("|");
else
printf(" ");
}
printf("\n");
}
printf("\n");
}
return 0;
}
标签:Picture,draw,Give,int,+---+,height,width,printf,Input 来源: https://blog.csdn.net/and_what_not/article/details/114768750