如何编写算法/程序以找到耗尽数字的方法组合。 [英] How do I write an algorithm/program to find combination of ways to exhaust a number.
问题描述
假设有 n轮胎可以被汽车,三轮车和自行车使用。我需要编写一个算法来接受n轮胎并生成所有可能的汽车组合(s) ),三轮车和自行车将耗尽n轮胎。
例如:
因为汽车需要4轮胎,三轮车需要3个轮胎,自行车需要2个轮胎,EXHAUST 10轮胎的所有可能组合如下:
2辆汽车和1辆自行车
1汽车和3辆自行车
1辆汽车和2辆三轮车
2辆三轮车和2辆自行车
5辆自行车。
以下是汽车,三轮车和自行车可以排出10个轮胎的所有组合。
请帮助我可以生成上述n轮胎组合的任何语言代码(最好是C#)。
谢谢
Assuming that there are n tyres that could be used by a car,tricycle and a bicycle. I need to write an algorithm to accept n-tyres and generate all d possible combinations of car(s), tricycle(s) and bicycle(s) that will exhaust the n-tyres.
For example:
Since cars need 4 tyres, tricycles need 3 tyres and bicycles need 2 tyres, the all the possible combinations to EXHAUST 10 tyres are listed below:
2 Cars and 1 Bicycle
1 Car and 3 Bicycles
1 Car and 2 Tricycles
2 Tricycles and 2 Bicycle
5 Bicycles.
These are all the combinations possible for car, tricycle and bicycle to exhaust 10 tyres.
Please can you help me with the code in any language (preferably in C#) that can generate the combinations above for n-tyres.
Thanks
推荐答案
是的如果你请参阅下面的链接你会发现来自CP的许多资源
C#组合 [ ^ ]
Yes If you refer below Link You will find many resources from CP
combinations C#[^]
这篇关于如何编写算法/程序以找到耗尽数字的方法组合。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!