@@ -0,0 +1,1959 @@
+//  Copyright 2016 The Sawdust Open Source Project%0A//%0A// Licensed under the Apache License, Version 2.0 (the %22License%22);%0A// you may not use this file except in compliance with the License.%0A// You may obtain a copy of the License at%0A//%0A//     http://www.apache.org/licenses/LICENSE-2.0%0A//%0A// Unless required by applicable law or agreed to in writing, software%0A// distributed under the License is distributed on an %22AS IS%22 BASIS,%0A// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A// See the License for the specific language governing permissions and%0A// limitations under the License.%0A//%0A%0Apackage backtracing;%0A%0Aimport java.util.Arrays;%0Aimport java.util.LinkedList;%0Aimport java.util.List;%0A%0Apublic class ChangeMoney %7B%0A    private int%5B%5D currencys;%0A    private int solutonsNum;%0A%0A    public ChangeMoney(int%5B%5D currencys) %7B%0A        this.currencys = currencys;%0A    %7D%0A    %0A    private void select(int from, int target, List solution) %7B%0A        for (int i = from; i %3C currencys.length; i++) %7B%0A            int v = currencys%5Bi%5D;%0A            int nextTarget = target - v;%0A            if (nextTarget == 0) %7B%0A                solution.add(currencys%5Bi%5D);%0A                solutonsNum++;%0A                System.out.println(solution.toString());%0A%0A                solution.remove(solution.size() - 1);%0A                return;%0A            %7D%0A            if (nextTarget %3C 0) %7B%0A                return;%0A            %7D%0A            solution.add(currencys%5Bi%5D);%0A            select(i, nextTarget, solution);%0A            solution.remove(solution.size() - 1);%0A        %7D%0A    %7D%0A%0A    public void changeWays(int target) %7B%0A        Arrays.sort(currencys);%0A        solutonsNum = 0;%0A%0A        List%3CInteger%3E solution = new LinkedList%3C%3E();%0A        select(0, target, solution);%0A%0A        System.out.println(%22in total:%22 + solutonsNum);%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        ChangeMoney cm = new ChangeMoney(new int%5B%5D%7B1, 2, 5%7D);%0A        cm.changeWays(4);%0A    %7D%0A%7D%0A

Change money