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>
int main()
{
int i,j,m,n;
char a[80][80];
while(scanf("%d%d",&m,&n) != EOF)
{
for(i = 0; i <= n;i ++)
for(j = 0; j <= m; j ++)
a[i][j] = ' ';
for(i = 0; i <= n+1; i ++)
{
for(j = 0; j <= m+1; j ++)
{
a[i][0] = '|';
a[i][m+1] = '|';
a[0][j] = a[n+1][j] = '-';
}
}
a[0][0] = '+';
a[0][m+1] = '+';
a[n+1][0] = '+';
a[n+1][m+1] = '+';
for(i = 0; i <= n+1; i ++)
{
for(j = 0; j <= m+1; j ++)
printf("%c",a[i][j]);
printf("\n");
}
printf("\n");
}
return 0;
}