1 条题解

  • 0
    @ 2026-8-28 20:00:19

    #include<bits/stdc++.h> using namespace std;

    int main(){ int n; char c; int t; cin >> n >> c >> t;

    for(int i = 1; i <= n; i++){
        if(t == 1){
            // 实心三角形
            for(int j = 1; j <= i; j++){
                cout << c;
            }
        } else {
            // 空心三角形
            if(i == 1 || i == n){
                // 第一行或最后一行
                for(int j = 1; j <= i; j++){
                    cout << c;
                }
            } else {
                // 中间行
                cout << c;
                for(int j = 1; j <= i - 2; j++){
                    cout << " ";
                }
                cout << c;
            }
        }
        cout << endl;
    }
    
    return 0;
    

    }

    • 1

    信息

    ID
    268
    时间
    1000ms
    内存
    256MiB
    难度
    10
    标签
    递交数
    2
    已通过
    1
    上传者