给出一个数组。我们需要找到所有可能的子阵列及其总和..可以帮助吗? [英] given an array . we need to find all possible sub arrays and their sums..can any one help?

查看:65
本文介绍了给出一个数组。我们需要找到所有可能的子阵列及其总和..可以帮助吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果array = {1,2,3,4}

子阵列

{1,2} {1,3} {1,4} {2 ,3} {3,4} {1,2,3} {2,3,4} ...及各自的金额

给出任何想法。

if array={1,2,3,4}
sub arrays
{1,2} {1,3} {1,4} {2,3} {3,4} {1,2,3} {2,3,4}...and thier respective sums
give any idea.

推荐答案

你要找的东西叫做组合 - 那里有很多关于它们的东西,其中一些可能对你有用。谷歌在制定算法方面可以提供很多帮助。



但是......这是你的功课,你自己做的很重要:它设置为原因。它就是为了让你思考你被告知的事情,并试着理解它。它也在那里,以便您的导师可以识别您身体虚弱的区域,并将更多的注意力集中在补救措施上。



亲自尝试,你可能会发现它不是和你想的一样困难!



如果遇到具体问题,请询问相关问题,我们会尽力提供帮助。但是你自己尝试是非常重要的。
What you are looking for is called "Combinations" - and there is a lot about them out there, some of which may be useful to you. Google can help a lot here in working out the algorithm.

But...it's your homework, and it's important that you do it yourself: 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!

If you meet a specific problem, then please ask about that and we will do our best to help. But it is very important that you try for yourself.


这篇关于给出一个数组。我们需要找到所有可能的子阵列及其总和..可以帮助吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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