HDoj 2052 Picture
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.
after each case, you should a blank line.
Sample Input
3 2
Sample Output
+---+
| |
| |
+---+
Author
xhd
Source
Recommend
C语言代码如下:
#include<stdio.h> int main() { int x,y; while(scanf("%d%d",&x,&y)!=EOF) { x+=2; y+=2; for(int i=0;i<y;i++) { for(int j=0;j<x;j++) { if((i==0&&j==0) ||(i==0&&j==x-1)||(i==y-1&&j==0)||(i==y-1&&j==x-1)) printf("+"); else if(i==0||i==y-1) printf("-"); else if(j==0||j==x-1) printf("|"); else printf(" "); } printf("\n"); } printf("\n"); } }
浙公网安备 33010602011771号