GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — java_visualize/example-code/Knapsack.java at master · patrick-slagle/java_visualize Expand file tree/ Copy pathKnapsack.javaMore file actions 13 lines (13 loc) · 420 Bytes / Copy pathKnapsack.javaFile metadata and controls13 lines (13 loc) · 420 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 public class Knapsack { public static void main(String[] args) { int[] itemSizes = {3, 5, 6, 8}; int capacity = 15; boolean[] canMakeSum = new boolean[capacity+1]; canMakeSum[0] = true; for (int size : itemSizes) { for (int i=capacity; i>=size; i--) canMakeSum[i] |= canMakeSum[i-size]; } System.out.println(java.util.Arrays.toString(canMakeSum)); } } |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |