//
// main.cpp
// beibao01_穷举法
//
// Created by 瑛峰 on 14/12/23.
// Copyright (c) 2014年 angran. All rights reserved.
//
#include
#include
#include
#define MAX 100
using namespace std;
//将n化为二进制形式,结果存放到数组b中,这个二进制其实不是真的二进制,因为没有反序,比如3二进制是011,它存得却是1,1,0。但是这里只是作为 组合 的 枚举的,所以关系不大。这是我的理解
void conversion(int n,int b[MAX])
{cout<< "["<>n;// 输入物品个数
// cout<<"please input tw:";
// cin>>tw;// 输入背包的限制重量
// //输入各个物品的重量
// cout<<"please input the weight : ";
//
// for(i=0;i>w[i];
//
// }
//
// //输入各个物品的价值
// cout<<"please input the value : ";
// for(i=0;i>w[i]; }
n = 3;
tw = 10;
w[0] = 3;
w[1] = 4;
w[2] = 5;
v[0] = 4;
v[1] = 5;
v[2] = 6;
maxv = 0;
/*穷举2n个可能的选择,找出物品的最佳选择*/
for (i=0;imaxv))
{
枚举法 背包问题01
最新推荐文章于 2022-01-29 18:10:11 发布