动态规划求0_1背包问题
文章作者 100test 发表时间 2011:03:18 20:32:07
来源 100Test.Com百考试题网
#include
#include
#include
//goods是一个或多个物品的重量和价值
typedef struct goods
{
int weight.
int value.
} goods.
//用来定义一个queryList数组
//数组中的每个元素定义一趟需要记录的数据
typedef struct queryList
{
goods *subResult. //一趟需要记录的数据
int end. //指示该趟数据的最后一个元素
} queryList.
queryList* dknap(goods *Goods, int count, int capacity)
{
int i, j, next, pre, index, k.
queryList *ql.
goods cur.
ql = (queryList *)malloc(sizeof(queryList)*count).
ql[0].subResult = (goods*)malloc(sizeof(goods)).
ql[0].end = 0.
ql[0].subResult-