/* 递归实现 C(m,n) */#include "stdio.h"
int m,n,s,a[20];int main()
{int c(int k);s=0; a[0]=0;scanf("%d%d",&m,&n);printf("\nC(%d,%d)=%d\n",m,n,c(1));}//组合递归函数C(k)
int c(int k)
{int i,j;if(k<=n){for(i=a[k-1]+1;i<=m;i++){a[k]=i;if(k==n) //已到n个数时,则打印出一个解{s++;for(j=1;j<=n;j++)printf("%d",a[j]);printf(" ");if(s%10==0) printf("\n");}else c(k+1); //没有到n个数,则继续探索下一个数}}return s;
}