import java.util.*;
import java.lang.*;
import java.io.*;
class Main{
    public static void main(String[] args) {
        Scanner teclado = new Scanner(System.in);
        int nfilas = teclado.nextInt();
        int a[] = new int[1];
        for (int i = 1; i <= nfilas; i++) {
            int x[] = new int[i];
            for (int j = 0; j < i; j++) {
                if (j == 0 || j == (i - 1)) {
                    x[j] = 1;
                } else {
                    x[j] = a[j] + a[j - 1];
                }
                System.out.print(x[j] + " ");
            }
            a = x ;
            System.out.println();
        }
    }
}

Embed on website

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