杭电2052Picture

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2052

本题就是一个构造图形的问题:

#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    char str[75][75];
    int m,n;
    
    while(cin>>m>>n)
    {
      //对str初始化 
      for(int i=0;i<n+2;i++)
      {
        for(int j=0;j<m+2;j++)
          str[i][j]=' ';
      }
      str[0][0]='+';
      for(int i=1;i<m+1;i++)
        str[0][i]='-';
      str[0][m+1]='+';
      for(int j=1;j<n+1;j++)
        str[j][0]='|';
      str[n+1][0]='+';
      for(int i=1;i<m+1;i++)
        str[n+1][i]='-';
      str[n+1][m+1]='+';
      for(int j=1;j<n+1;j++)
        str[j][m+1]='|';
      
      for(int i=0;i<n+2;i++)
      {
        for(int j=0;j<m+2;j++)
        {
            cout<<str[i][j];   
        }  
        cout<<endl;
      }
    cout<<endl;
    }
    system("PAUSE");
    return EXIT_SUCCESS;
}
原文地址:https://www.cnblogs.com/gkfeng/p/2620023.html