【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;
}
上一篇:谷歌(Google)被墙,解决地图和字体无法显示的问题


下一篇:红与黑