//输出m行m列的空心正方矩形。
    int m;//m用来控制行列数。
    cout<<"请输入要打印的行列数n(n>=4):\n";
    cin>>m;
    for(int i=0;i<m;i++)//控制打印的行数
    {
        for(int j=0;j<m;j++)
        {
            if(i==0||i==m-1)
            {
                cout<<"* ";//星号后有一个空格
            }
            else
                if(j==0||j==m-1)
                {
                    cout<<"* ";
                }
                else
                    cout<<"  ";
        }
        cout<<endl;
    }

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-04
  • 2021-11-14
  • 2022-12-23
  • 2021-12-17
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-18
相关资源
相似解决方案