在1到20中求13个数的所有组合,不是求组合数,是求出所有的组合,希望有matlab代码
来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/10/04 21:32:04
在1到20中求13个数的所有组合,不是求组合数,是求出所有的组合,希望有matlab代码
In matlab,you can use a function to obtain the combinations:nchoosek()
For example:
>> nchoosek(20,13) % get the total number of choosing 13 from 20,which is 77520
ans =
77520
>> y = nchoosek(1:20,13); % get all combinations of choosing 13 from 20
>> size(y)
ans =
77520 13
the list of y is too long to fit here,let's see the first few rows:
>> y(1:5,:)
ans =
1 2 3 4 5 6 7 8 9 10 11 12 13
1 2 3 4 5 6 7 8 9 10 11 12 14
1 2 3 4 5 6 7 8 9 10 11 12 15
1 2 3 4 5 6 7 8 9 10 11 12 16
1 2 3 4 5 6 7 8 9 10 11 12 17
Let me give you another full example,such as choosing 3 from 6:
>> nchoosek(1:6,3)
ans =
1 2 3
1 2 4
1 2 5
1 2 6
1 3 4
1 3 5
1 3 6
1 4 5
1 4 6
1 5 6
2 3 4
2 3 5
2 3 6
2 4 5
2 4 6
2 5 6
3 4 5
3 4 6
3 5 6
4 5 6
For example:
>> nchoosek(20,13) % get the total number of choosing 13 from 20,which is 77520
ans =
77520
>> y = nchoosek(1:20,13); % get all combinations of choosing 13 from 20
>> size(y)
ans =
77520 13
the list of y is too long to fit here,let's see the first few rows:
>> y(1:5,:)
ans =
1 2 3 4 5 6 7 8 9 10 11 12 13
1 2 3 4 5 6 7 8 9 10 11 12 14
1 2 3 4 5 6 7 8 9 10 11 12 15
1 2 3 4 5 6 7 8 9 10 11 12 16
1 2 3 4 5 6 7 8 9 10 11 12 17
Let me give you another full example,such as choosing 3 from 6:
>> nchoosek(1:6,3)
ans =
1 2 3
1 2 4
1 2 5
1 2 6
1 3 4
1 3 5
1 3 6
1 4 5
1 4 6
1 5 6
2 3 4
2 3 5
2 3 6
2 4 5
2 4 6
2 5 6
3 4 5
3 4 6
3 5 6
4 5 6
在1到20中求13个数的所有组合,不是求组合数,是求出所有的组合,希望有matlab代码
MATLAB问题,给出一个数,求所有组合
编程,在0123456789 10个数中输入5个数随机组合,将所有一行五个数字的组合数全都列出来
求从0到9任选5个数(可以重复),5个数相加等于22的所有组合!
求枚举组合算法1-8 的所有6位组合123456124653135721.任意的都要组合,不能漏掉可能组合的任意一组..
1.2.3.4.34.35中寻找能够组合成和为60-100的数,每组组合为5个数,求个公式.最好是有公式的.
求任意选7个数组合代码
6组数 每组两个数 想在每组数中选一个组合成新的一组数 并显示所有的组合 在excel中如何实现 求指教
VB编程题目单击按钮随机产生5个0-9之间不同的整数并排序,试求出5个数能组合的所有5位数显示在文本框中,并求出最大数和
求英语48个音标读音的所有字母组合
求1 java算法 一个数组中m个数(连续的) 需要分成n组 求这n组的所有组合方式
matlab求n个数中取m个的全组合.