#include <stdio.h>
void Combin(int m,int n,int a){ if(m == n){ if(a>0)printf("%d",a); while(n > 0) printf("%d",n--); printf("\n"); return; } else if(0 == n){ printf("%d ",a); return; } Combin(m-1,n-1,a*10+m); Combin(m-1,n,a);}
int main(){ Combin(9,5,0);}
代码返回:
98765 98764 98763 98762 9876198754 98753 98752 9875198743 98742 9874198732 987319872198654 98653 98652 9865198643 98642 9864198632 9863198621
由于本段代码测试数据太长,就不多输出了,自己试下吧!