求和算法

Java68

给定一个数组和一个目标值,计算得出目标值的所有组合,重复值将出现在组合中,每个重复值在每个组合中只能出现一次。

[En]

Given an array and a target value, calculate all combinations that sum up to the target value, and duplicate values will appear in the combination, and each duplicate value can only appear once in each combination.

包含小数。

```java;gutter:true;
import java.util.*;

public class Match {

public static void main(String[] args) {
    Double[] nums = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 5.5, 0.5, 0.5, 0.4};
    List nlist = Arrays.asList(nums);
    Double target = 8.0;

    List> result = sum(nlist, target, null);
    for (List doubles : result) {
        System.out.println(Arrays.toString(new List[]{doubles}));
    }
}
输入验证码查看隐藏内容

扫描二维码关注本站微信公众号 Johngo学长
或者在微信里搜索 Johngo学长
回复 svip 获取验证码
wechat Johngo学长