标签:
#include <iostream.h>
#include <stdio.h>
int Number(int x, int y);
void main (void)
{
int i;
int j;
int k;
int n;
cout << "请输入 N=";
cin >> n;
for (i=0; i<=n; i++)
{
for (k=0; k<24-2*i; k++)
{
printf (" ");
}
for (j=1; j<i+2; j++)
{
printf ("%4d", Number(i, j));
}
printf ("\n");
}
}
int Number (int x, int y)
{
int z;
if ((y==1) || (y==x+1))
{
return 1;
}
z=Number(x-1, y-1) + Number(x-1, y);
return z;
}
运行截图:
标签:
原文地址:http://www.cnblogs.com/milantgh/p/4540056.html