#include<stdio.h> int a[1000][1000]; int yang(int x,int y) { if(a[x][y]==0) { if(x==y||y==1)a[x][y]=1; else a[x][y]=yang(x-1,y)+yang(x-1,y-1); } return a[x][y]; } int main(int argc, char *argv[]) { int n; while(~scanf("%d",&n)) { if(n<2) continue; for(int i=2;i<=n;++i) { for(int j=1;j<=i-1;++j) { printf("%d ",yang(i,j)); } printf("%d\n",yang(i,i)); } } return 0; } /************************************************************** Problem: 1073 User: kirchhoff Language: C Result: Accepted Time:10 ms Memory:4820 kb ****************************************************************/
原文地址:http://blog.csdn.net/wdkirchhoff/article/details/42100885