pascal triangle Algorithm

In much of the Western universe, it is named after the French mathematician Blaise Pascal, although other mathematicians study it centuries before him in India, Persia (Iran), China, Germany, and Italy. The entry in each row are numbered from the left beginning with K = 0 and are normally staggered relative to the numbers in the adjacent rows. 

In Italy, Pascal's triangle is referred to as Tartaglia's triangle, named for the Italian algebraist Niccolò Fontana Tartaglia (1500–1577), who published six rows of the triangle in 1556.Gerolamo Cardano, also, published the triangle as well as the additive and multiplicative rules for constructing it in 1570.Pascal's Traité du triangle arithmétiqueThe triangle was later named after Pascal by Pierre Raymond de Montmort (1708) who named it" table de M. Pascal pour les combinaisons"(French: table of Mr. Pascal for combinations) and Abraham de Moivre (1730) who named it" Triangulum Arithmeticum PASCALIANUM"
#include<iostream>

using namespace std;

void show_pascal(int **arr, int n)
{
	//pint Pascal's Triangle
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < n + i; ++j)
		{
			if (arr[i][j] == 0)
				cout << " ";
			else
				cout << arr[i][j];
		}
		cout << endl;
	}
}

int **pascal_triangle(int **arr, int n)
{
	for (int i = 0; i < n; ++i)
	{
		for (int j = n - i - 1; j < n + i; ++j)
		{
			if (j == n - i - 1 || j == n + i - 1)
				arr[i][j] = 1;				//The edge of the Pascal triangle goes in 1
			else
				arr[i][j] = arr[i - 1][j - 1] + arr[i - 1][j + 1];
		}
	}

	return arr;
}

int main()
{
	int n = 0;

	cout << "Set Pascal's Triangle Height" << endl;
	cin >> n;
	
	//memory allocation (Assign two-dimensional array to store Pascal triangle)
	int **arr = new int*[n];
	for (int i = 0; i < n; ++i)
	{
		arr[i] = new int[2 * n - 1];
		memset(arr[i], 0, sizeof(int)*(2 * n - 1));
	}
	
	pascal_triangle(arr, n);
	show_pascal(arr, n);

	//deallocation
	for (int i = 0; i < n; ++i)
	{
		delete[] arr[i];
	}
	delete[] arr;

	return 0;
}

LANGUAGE:

DARK MODE: