1 solutions

  • 0
    @ 2026-11-5 20:18:04
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        int n;
        cin >> n;
        for(int i = 1; i <= n; i++)
        {
            for(int j = 1; j <= n; j++)
            {
                //四个顶点
                if((i==1&&j==1)||(i==1&&j==n)||(i==n&&j==1)||(i==n&&j==n))
                {
                    cout << "+";
                }
                //第一行、最后一行,中间是'-'
                else if(i==1 || i==n)
                {
                    cout << "-";
                }
                //第一列、最后一列,中间是'|'
                else if(j==1 || j==n)
                {
                    cout << "|";
                }
                //内部*
                else
                {
                    cout << "*";
                }
            }
            cout << endl;
        }
       
    
    }
    

    Information

    ID
    308
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    1
    Tags
    (None)
    # Submissions
    15
    Accepted
    12
    Uploaded By