English 中文(简体)
A. 寻找具有条件的特定阵列数目
原标题:Algorithm to find set of numbers of a given array with a condition

Given an integer array of size N by the user. Print all the possible sets such that sum of all possible numbers equate to a number in the array.

Example:

Array A[]= {1,2,3,4,5}

1+2=3.Output:1,2,3

1+3=4。 产出:1,3,4

1+4=5。 产出:1,4,5

初步设计:

  1. Take a number and set it to SetSum
  2. Generate all sums excluding the selected number; checking that the formulated sum is same as the SetSum
  3. Print out the numbers that satisfies the conditions above.
  4. Iterate over the array and set the next number as SetSum

欢迎采用高效的设计/实施或不同的方法。

最佳回答

这个问题要求你找到其总额达到一定数目的子点(如果是一组要素的话)。 这样做有两点:

  1. a. 简明的部队算法,其中你人工生成所有子集,并将其全部按指数顺序排列(2个紧急组合)或

  2. 采用动态的方案拟订办法处理这一问题,并在多长时间内找到这笔钱。 这是计算法的一个标准问题,称为子集和问题。 如果你不熟悉动态方案规划的概念,你可以研究任何算法文本。 如果你们理解动态的方案规划,那么,就子集总问题而言,就显得.。 希望帮助!

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签