杭电2052

此题是一道简单的画图题!!只要掌握规律还是很容易的!呵呵!!

首先注意输入的是 长n 高m,还有就是注意‘+“号就行了!

 

 

#include<iostream>
using namespace std;
int main()
{
 int n,m,i,j;
 while(cin>>n>>m)
 {
  for(i=0;i<m+2;i++)
  {     for(j=0;j<n+2;j++)
   {
    if(i==0&&j==0||i==0&&j==n+1||i==m+1&&j==0||i==m+1&&j==n+1)
     cout<<'+';
     else
     if(i==0||i==m+1)
      cout<<'-';
       else
        if(j==0||j==n+1)
         cout<<'|';
        else
         cout<<' ';}
  cout<<endl;}
   
   cout<<endl;
 }
 return 0;
}
  

你可能感兴趣的:(杭电)