编程输出从1,2,3,4,5,6中任选3个数组成的所有组合

[复制链接]
查看11 | 回复2 | 2011-9-19 19:26:58 | 显示全部楼层 |阅读模式
#include #include #include // 计算 n! int fact(int n){ long f;if (n ==0 || n == 1) {return 1;}
else{ return fact(n-1)*n;}}// 计算组合数 C(m,n) int cmn(int m,int n){if(m>n){return 0;}else{return fact(n)/fact(m)/fact(n-m);}}void permutationAndCombina...
回复

使用道具 举报

千问 | 2011-9-19 19:26:58 | 显示全部楼层
3层for循环int a,b,c;for(a=1;a<7;a++)for(b=1;b<7;b++)for(c=1;c<7;c++)if(a!=b&&b!=c&&a!=c)printf("%d %d %d\n",a,b,c);...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行