文件名称:2
- 所属分类:
- 控制台(字符窗口)编程
- 资源属性:
- [Windows] [Visual C] [源码]
- 上传时间:
- 2012-11-26
- 文件大小:
- 176kb
- 下载次数:
- 0次
- 提 供 者:
- STar****
- 相关连接:
- 无
- 下载说明:
- 别用迅雷下载,失败请重下,重下不扣分!
介绍说明--下载内容均来自于网络,请自行研究使用
用回溯解背包问题 假设有n件物品,定义一个结构体a[]来存储,结构体有两个成员weight和value(weight表示重量,value表示价值)先定义一个数组col[]表示每个物品当前状态(为1表示被选,为0表示未被选),其初值全为1,从下标为0开始遍历,当前所选物品总重和总价值分别设为tw和tv(初值均为0),背包的限重设为limit,若第i个物品满足tw+a[i].weight<=limit且col[i]==1 就将a[i].weight和value加入tw和tv,否则col[i]设为0。-Knapsack problem using backtracking solution assumption has n items, the definition of a structure a [] to store, structure, body weight and has two members value (weight, said weight, value, said value) before the definition of an array col [] mean that each and every item current status (as one said to be elected, not selected to express to 0), all of its initial value 1, from the beginning subscr ipt 0 ergodicity, the currently selected items and the total value of gross weight, respectively, as tw and tv (early values are 0), backpack weight limit is set to limit, if paragraph i of goods to meet tw+ a [i]. weight
(系统自动生成,下载前可以参看下载内容)
下载文件列表
2
.\2.cpp
.\2.dsp
.\2.dsw
.\2.ncb
.\2.opt
.\2.plg
.\Debug
.\2.cpp
.\2.dsp
.\2.dsw
.\2.ncb
.\2.opt
.\2.plg
.\Debug