1 条题解

  • 5
    @ 2023-9-2 22:04:21

    没人发?那我搞个

    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        int a;
        cin >> a;
        for (int i = 1;i < a;i++)
        {
            cout << " ";
        }
        for (int i = 1;i <= a;i++)
        {
            cout << "*";
        }
        cout << endl;
        for (int i = 1;i < a;i++)
        {
            for (int j = 1;j <= a - i - 1;j++)
            {
                cout << " ";
            }
            cout << "*";
            for (int j = 1;j <= a + (i - 1) * 2;j++)
            {
                cout << " ";
            }
            cout << "*";
            cout << endl;
        }
        for (int i = a - 2;i > 0;i--)
        {
            for (int j = 1;j <= a - i - 1;j++)
            {
                cout << " ";
            }
            cout << "*";
            for (int j = 1;j <= a + (i - 1) * 2;j++)
            {
                cout << " ";
            }
            cout << "*";
            cout << endl;
        }
        for (int i = 1;i < a;i++)
        {
            cout << " ";
        }
        for (int i = 1;i <= a;i++)
        {
            cout << "*";
        }
        cout << endl;
    }//已AC,请放心食用
    
    • 1

    信息

    ID
    226
    时间
    1000ms
    内存
    16MiB
    难度
    1
    标签
    递交数
    61
    已通过
    45
    上传者