我在大学里的递归任务有问题!请看一下。 [英] I have trouble with my recursion task in university! please, take a look.

查看:77
本文介绍了我在大学里的递归任务有问题!请看一下。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,



我正在大学学习,我必须用递归制作一个程序。但我无法弄清楚从哪里开始。



基本上我有2个{1-10}的5个随机数和{25; 50; 75个; 100}。

最终号码是{100-999}。我必须编写一个程序,用这6个随机数使用数学运算(+; - ; *; /)来计算我的最终数字。程序应该解决它不到5秒,并且只使用一次数字。



对不起我的英语。这是一个例子:



4 4 7 8 9 100 - >随机数

380 - >最终号码(获得)



解决方案:



4 * 100 = 400

9 + 8 = 17

7 + 17 = 24

24 - 4 = 20

400 - 20 = 380






4 * 9 = 36

4 + 36 = 40

7 * 40 = 280

280 + 100 = 380

(未使用8)



也应该有无法计算的情况。



我现在真的很挣扎,感觉我不是想学习递归,但只是浪费我的时间在一个困难的数学上。我不一定想要一个代码作为回应,我非常感谢如何以最简单的方式解决这个数学问题的解释...我只能想到经历所有可能的结果,它真的是无效和坏的imo。通常我有一个计划做什么,我知道它已经完成了。我通常遇到的问题是编写代码。但是现在,我不知道如何解决它...



提前致谢!



我尝试了什么:



我想不出正确的方法来运行递归。只是试图贯穿所有可能的结果。哪个也不容易...

Hello,

I'm studying in university and I have to make one program with recursion. But I just cannot figure out where to start.

Basically I have 5 random numbers from 2x{1-10} and one more from {25;50;75;100}.
Final number is {100-999}. I have to write a program that calculates my final number using mathematical operations (+;-;*;/) with those 6 random numbers. Program should solve it for less than 5 secs and use numbers only once.

Sorry for my English. Here is an example:

4 4 7 8 9 100 -> Random numbers
380 -> Final number (to get)

Solutions:

4 * 100 = 400
9 + 8 = 17
7 + 17 = 24
24 – 4 = 20
400 – 20 = 380

or

4 * 9 = 36
4 + 36 = 40
7 * 40 = 280
280 + 100 = 380
(did not use 8)

There also should be situation where It would not be possible to calculate.

I'm really struggling right now, It feels like I am not trying to learn recursion but just waste my time on a difficult mathematical stuff. I don't necessarily want a code in response, I would greatly appreciate an explanation how to solve this mathematical problem the easiest way possible... I can only think of going through all possible outcomes and it's really ineffective and bad imo. Usually I have a plan what to do, and I know hows it's done. The problems I usually have is to write a code. But now, I have no idea how to solve it...

Thanks in advance!

What I have tried:

I just cannot think of proper way to run the recursion. Only trying to run through all of possible outcomes. Which is not easy as well...

推荐答案

我们不做你的作业:这是有原因的。它就是为了让你思考你被告知的事情,并试着理解它。它也在那里,以便您的导师可以识别您身体虚弱的区域,并将更多的注意力集中在补救措施上。



亲自尝试,你可能会发现它不是你想的很难!

(经OriginalGriff许可使用)



如果您显示某些特定问题的代码,我们可能会帮助您,否则,ir是错误的地方。
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!
(Used with permission of OriginalGriff)

If you show some code with a particular problem, we may help, otherwise, ir is the wrong place.


这篇关于我在大学里的递归任务有问题!请看一下。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆