#include <iostream>
#include <iomanip>
using namespace std;
#define MAX_ROW 30
#define MAX_COL 30
int main()
{
int m;
int yanghui[MAX_ROW][MAX_COL] = { {0} };
cin >> m;
for (int i = 0; i <m; i++)
{
yanghui[i][0] = yanghui[i][i] = 1; //若为i行的第0个元素,若为第i行第i列的元素的值为1
}
for (int i = 2; i < m; i++)
{
for (int j = 1; j < i; j++)
{
yanghui[i][j] = yanghui[i - 1][j - 1] + yanghui[i - 1][j];
}
}
//输出杨辉三角
for (int i = 0; i < m; i++)
{
for (int j = 0; j <= i; j++)
{
cout << setw(5) << yanghui[i][j];
}
cout << endl;
}
return 0;
}
#include <iomanip>
using namespace std;
#define MAX_ROW 30
#define MAX_COL 30
int main()
{
int m;
int yanghui[MAX_ROW][MAX_COL] = { {0} };
cin >> m;
for (int i = 0; i <m; i++)
{
yanghui[i][0] = yanghui[i][i] = 1; //若为i行的第0个元素,若为第i行第i列的元素的值为1
}
for (int i = 2; i < m; i++)
{
for (int j = 1; j < i; j++)
{
yanghui[i][j] = yanghui[i - 1][j - 1] + yanghui[i - 1][j];
}
}
//输出杨辉三角
for (int i = 0; i < m; i++)
{
for (int j = 0; j <= i; j++)
{
cout << setw(5) << yanghui[i][j];
}
cout << endl;
}
return 0;
}