/*
3.8 编写一个程序打印如图 3.1 所示的 n 阶杨辉三角形,其中 n 由用户输入,该值不
能大于 13。
*/
#include <iostream>
using namespace std;
void main()
{
int a[13][13] = {0};
//memset(a, '1', sizeof(a));
a[0][0] = 1;
a[1][0] = 1;
a[1][1] = 1;
for (int j = 0; j < 13; j++)
{
a[j][0] = 1;
}
int n = 0;
int i = 0;
cin >> n;
while (n)
{
for (int j = 0; j <= i; j++)
{
if ((i - 1 >= 0) && (j - 1 >= 0))
{
a[i][j] = a[i - 1][j - 1] + a[i - 1][j];
}
}
{
int k = n;
while (k)
{
cout << " ";
k--;
}
}
for (int j = 0; j <= i; j++)
{
cout <<" "<< a[i][j] << " ";
}
cout << endl;
i++;
n--;
}
system("pause");
}