6 solutions

  • -1
    @ 2024-10-1 11:20:19
    #include<bits/stdc++.h>
    using namespace std;
    int main(){
        int n;
        cin >> n;
        for(int i = 1;i<=2*n-1;i++){
            if(i == 1||i == 2*n -1){
                for(int j =1; j<=3*n-2;j++){
                    if(j>=n&&j<2*n){
                        cout << "*";
                    }
                    else
                        cout << " ";
                }
            }else{
                for(int k = 0;k<3*n-2;k++){
                    if(k == abs(n-i) || k == 2*n -1 + (i-2)||k == (n-i)+(3*n-3)){
                        cout << "*";
                    }else{
                        cout << " ";
                    }
                    //下边
                }
            }
            cout << endl;
    
        }
    
    
    
        return 0;
    

    Information

    ID
    66
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    3
    Tags
    (None)
    # Submissions
    73
    Accepted
    35
    Uploaded By