hdu2052

来源:互联网 发布:oracle的sql developer 编辑:程序博客网 时间:2024/05/16 06:05

Picture

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 23002    Accepted Submission(s): 11710


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
+---+| || |+---+
 


遇到的问题和解题思路:

       水题。不过记住要每组数据之间空一行。(you should a blank line.)。


给出代码:


#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>


using namespace std;


int n,m;
char a[100][100];


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



0 0
原创粉丝点击