#include <stdio.h>
int main()
{
int arr[11][11] = { 0 };
int i = 0;
int j = 0;
for (i = 0; i <10; i++)
{
for (j = 0; j <= i; j++)
{
arr[i][0] = 1;
if (i == j)
{
arr[i][j] = 1;
}
if (i>1 && j >= 1)
{
arr[i][j] = arr[i - 1][j - 1] + arr[i - 1][j];
}
}
}
for (i = 0; i < 10; i++)
{
for (j = 0; j < 10 - i; j++)
{
printf(" ");
}
for (j = 0; j <= i; j++)
{
printf("%2d ", arr[i][j]);
}
printf("\n");
}
return 0;
}
转载于:https://blog.51cto.com/10706198/1702847