#include <iostream>
using namespace std;

int main() {
    cout << "Enter a number : ";
    int n;
    cin >> n;
    cout << endl;
    
    int row = 1;
    while(row <= n){
        
        // printing spaces
        int space = n-row;
        while(space){
            cout << "- ";
            space -= 1;
        }
        
        // printing left triangle 
        int col = 1;
        while(col <= row){
            cout << col << " ";
            col += 1;
        }
        
        // printing right triangle
        int start = row - 1;
        while(start){
            cout << start << " ";
            start -= 1;
        }
        
        row += 1;
        cout << endl;
    }
}

Embed on website

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