无语了..怎么全是1//
VC6.0编译:程序代码:
#include<stdio.h> #include<stdlib.h> int Binomial(int n,int k) { int i,j; int **C=(int**)malloc(sizeof(int*)*(n+1)); for(i=0;i<n+1;++i) C[i]=(int*)malloc(sizeof(int)*(k+1)); for(i=0;i<=n;++i) for(j=0;j<=(k>i?i:k);++j) if(j==0||j==k) C[i][j]=1; else C[i][j]=C[i-1][j]+C[i-1][j-1]; int ret = C[n][k]; for(i=0;i<n+1;++i) free(C[i]); free(C); return ret; } int main(void) { int n,k; while(scanf("%d,%d",&n,&k)!=EOF) printf("%d\n",Binomial(n,k)); return 0; }