posts - 36,  comments - 3,  trackbacks - 0
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()
{
 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,代码人生 阅读(131) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航:
 
<2012年7月>
24252627282930
1234567
891011121314
15161718192021
22232425262728
2930311234

 一定要好好学习,天天向上!

常用链接

留言簿

随笔分类(8)

随笔档案(35)

文章分类

文章档案(1)

搜索

  •  

最新评论

阅读排行榜

评论排行榜