提示: 作者被禁止或删除 内容自动屏蔽
提示: 作者被禁止或删除 内容自动屏蔽
[此贴子已经被作者于2006-6-13 10:12:33编辑过]
#include "Stdio.h"
#include "Conio.h"
int YangHuiTriangle(unsigned int row,unsigned int col)
{ /*计算杨辉三角*/
if (col==1 || row==col) return 1;
return ( YangHuiTriangle(row-1,col-1)+YangHuiTriangle(row-1,col) );
}
ShowYangHui(int n)
{ /*打印杨辉三角*/
int row=1,col=1;
for (row=1;row<=n;row++)
{
for (col=1;col<=row;col++)
printf("%d ",YangHuiTriangle(row,col));
printf("\n\n");
}
}
int main(void)
{
int i;
printf("****************Yang Hui Triangle****************\n\n");
printf("input the high:");
scanf("%d",&i);
ShowYangHui(i);
getch();
return 0;
}