如何在不重复C ++的情况下创建组合数字 [英] How to create combinations numbers without repeating in C++
本文介绍了如何在不重复C ++的情况下创建组合数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
如何创建一个程序,要求用户输入10个数字,程序可以形成5个数字的所有组合而不重复。感谢您的任何建议。
解决方案
您可以从10个不同的数字组成5个数字的组合数量?你知道组合和排列的公式吗?
展开 | 选择 | Wrap | 行号
@donbock
喜欢donbock
这是组合公式:
c = n!/ (r!*(n - r)!)
c = 10!/(5!*(10 - 5)!)
c = 252没有重复的组合>
我想我不需要使用公式进行排列。感谢
Hi
How to create a program that ask to the user enter 10 numbers and the program can form all the combinations of 5 numbers without repeating. Thanks for any advice.解决方案How many combinations of 5 numbers can you form from ten distinct numbers? Do you know the formulas for combinations and permutations?
Expand|Select|Wrap|Line Numbers
@donbock
Hi donbock
This is the formula for combination:
c = n!/(r! * (n - r)!)
c = 10!/(5! * (10 - 5)!)
c = 252 COMBINATIONS WITHOUT REPETITION
I think I do not need to use the formula for permutation. Thanks
这篇关于如何在不重复C ++的情况下创建组合数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取
|
15天全站免登陆