3 2
+---+ | | | | +---+
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
int n,m;
while(cin>>n>>m)
{
char str[85][85];
memset(str,0,sizeof(str));
int i,j;
for(i=0;i<=m+1;i++)
{
for(j=0;j<=n+1;j++)
{
if(i==0 || i==m+1)
str[i][j]='-';
else
str[i][j]=' ';
if(j==0 || j==n+1)
str[i][j]='|';
}
}
str[0][0]=str[0][n+1]=str[m+1][0]=str[m+1][n+1]='+';
for(i=0;i<=m+1;i++)
{
for(j=0;j<=n+1;j++)
cout<<str[i][j];
cout<<endl;
}
cout<<endl;
}
return 0;
}原文地址:http://blog.csdn.net/hyccfy/article/details/38037197