本文介绍了组合算法帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我正在创建一个组合算法。以下是挑战细节:您需要创建一个程序来接受4个整数输入,表示与鱼的价值相关的点(前三个整数输入代表三种不同的鱼),然后查看总数中可以容纳多少组合(最后一个整数输入表示你可以拥有的鱼点总数)。



输入在控制台程序中会是这样的,

1 //鱼点值

2 //鱼2点值

3 //鱼3点值

2 //总金额有人可以在没有超出限制的情况下获得积分



输出将显示如下,

1 Brown Trout,0 Northern Pike,0黄色小鱼崽

2棕色鳟鱼,0个北派克,0个黄色小鱼崽

0棕色鳟鱼,1个北派克,0个黄色小鱼肉

捕鱼的方法:3



我已经给了一些提示,比如在循环中使用循环和t o使用while循环,但我仍然很新,很困惑。任何提示或可能会使这个程序发生的示例代码?

So, I'm creating a combination algorithm. Here are the challenge details: You need to create a program to accept 4 integer inputs, representing points associated with how much a fish is worth (first three integer inputs representing three different fish) and then see how many combinations can fit into the total amount (last integer input representing the total amount of fish points you can have).

The input would be like this in a console program,
1 // fish point value
2 // fish 2 point value
3 // fish 3 point value
2 // total amount of points somebody can have without exceeding the limit

The output would be displayed like this,
1 Brown Trout, 0 Northern Pike, 0 Yellow Pickerel
2 Brown Trout, 0 Northern Pike, 0 Yellow Pickerel
0 Brown Trout, 1 Northern Pike, 0 Yellow Pickerel
Number of ways to catch fish: 3

I've been given some tips like using loops inside of loops and to use a while loop, but I'm still pretty new and confused. Any tips or maybe some sample code that would make this program happen?

推荐答案


这篇关于组合算法帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 08:49