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
Sample Output
+---+
| |
| |
+---+
#include<stdio.h>
int main()
{
char a[1000];
char b[80][10000];
int n,m;
while((scanf("%d%d",&n,&m))!=EOF&&m<75)
{
getchar();
a[0]=a[n+1]='+';
int i,j;
for(i=1;i<=n;i++)
a[i]='-';
for(j=1;j<m+1;j++)
{
for(i=0;i<=n+1;i++)
{ if(i==0||i==n+1)
b[j][i]='|';
else
b[j][i]=' ';
}
}
for(i=0;i<=n+1;i++)
printf("%c",a[i]);
printf("\n");
for(i=1;i<=m;i++)
{
for(j=0;j<=n+1;j++)
{
printf("%c",b[i][j]);
}
printf("\n");
}
for(i=0;i<=n+1;i++)
printf("%c",a[i]);
printf("\n\n");
}
}
posted on 2012-07-13 16:51
天YU地___PS,代码人生 阅读(160)
评论(0) 编辑 收藏