Picture:
#include<iostream>
using namespace std;
#define N 1000
char str[N][N];
int main(){
int width,height;
while(cin>>width>>height){
int i,j;
for(i=0;i<N;++i)
for(j=0;j<N;++j)
str[i][j]=' ';
str[1][1]='+';
str[1][width+2]='+';
str[height+2][1]='+';
str[height+2][width+2]='+';
for(i=2;i<=width+1;++i)
str[1][i]='-';
for(i=2;i<=height+1;++i)
str[i][1]='|';
for(i=2;i<=height+1;++i)
str[i][width+2]='|';
for(i=2;i<=width+1;++i)
str[height+2][i]='-';
for(i=1;i<=height+2;++i){
for(j=1;j<=width+2;++j){
cout<<str[i][j];
if(j==width+2)
cout<<endl;
}
}
cout<<endl;
}
return 0;
}
转载于:https://blog.51cto.com/beyond316/1258884