#include<iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a = n;
    for(int i = 1; i <= n; i++){
        for(int j = 0; j < a-1; j++){
            cout<<" ";
        }
        for(int j = 1; j <= i*2-1; j++){
            cout<<"*";
        }
        a--;
        cout<<"\n";
    }
    n--;
    for(int i = 0; i < n; i++){
        cout<<" ";
        for(int j = 0; j < i; j++){
            cout<<" ";
        }
        for(int j = 0; j < 2*(n-i)-1; j++){
            cout << "*";
        }
        cout << "\n";
    }
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: