[Java] Java通过动态规划法解决0-1背包问题代码 →→→→→进入此内容的聊天室

来自 , 2020-11-30, 写在 Java, 查看 105 次.
URL http://www.code666.cn/view/27bc42aa
  1. package algorithm.dynamicplan;  
  2. public class Knapsack {  
  3.      
  4.     /** 背包重量  */  
  5.     private int weight;  
  6.      
  7.     /** 背包物品价值  */  
  8.     private int value;  
  9.     /***
  10.      * 构造器
  11.      */  
  12.     public Knapsack(int weight, int value) {  
  13.         this.value = value;  
  14.         this.weight = weight;  
  15.     }  
  16.     public int getWeight() {  
  17.         return weight;  
  18.     }  
  19.      
  20.     public int getValue() {  
  21.         return value;  
  22.     }  
  23.      
  24.     public String toString() {  
  25.         return "[weight: " + weight + " " + "value: " + value + "]";    
  26.     }  
  27. }  
  28.  
  29.  
  30.  
  31.  
  32. //java/7212

回复 "Java通过动态规划法解决0-1背包问题代码"

这儿你可以回复上面这条便签

captcha