Picture
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 23002 Accepted Submission(s): 11710
after each case, you should a blank line.
3 2
+---+ | | | | +---+
遇到的问题和解题思路:
水题。不过记住要每组数据之间空一行。(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;
}