分页:
上一页 1 2 3 4 5 [6] 7 8 9 10 下一页
int option[N],cop[N];
struct { double weight;
double value;
}a[N];
int n;
void find(int i,double tw,double tv)
{ int k;
/*考虑物品i包含在当前方案中的可能性*/
if (tw+a[i].weight<=limitW)
{ cop[i]=1;
if (i<n-1) find(i+1,tw+a[i].weight,tv);
else
{ for (k=0;k<n;k++)
option[k]=cop[k];
maxv=tv;
}
cop[i]=0;
}
/*考虑物品i不包含在当前方案中的可能性*/
分页:
上一页 1 2 3 4 5 [6] 7 8 9 10 下一页