#include <iostream>
using namespace std;
long long dp[50][50] = {0,};

int main() {
    int n;
    cin >> n;
    dp[0][0] = 1;
    if (n == 1) {
        cout << 1;
        return 0;
    }
    dp[1][0] = 1;
    dp[1][1] = 1;

    int cnt = 3;
    for (int i = 2;i < n;i++) {
        for (int j = 1;j < cnt-1;j++) {
            dp[i][0] = 1;
            dp[i][cnt-1] = 1;
            dp[i][j] = dp[i-1][j-1]+dp[i-1][j];
        }
        cnt++;
    }

    for (int i = 0;i < n;i++) {
        for (int j = 0;j < n;j++) {
            if (dp[i][j] != 0) {
                cout << dp[i][j] << " "; 
            }
        }
        cout << "\n";
    }
    return 0;
}

Embed on website

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