有一批集装箱要装上一艘载重量为c的轮船。其中集装箱i的重量为Wi。最优装载问题要求确定在装载体积不受限制的情况下,将尽可能多的集装箱装上轮船。
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
typedef struct Node
{
int number;//序列中的第几个
int weight;//序列的重量
}node;
bool cmp(node x,node y)
{
if(x.weight<y.weight)
return true;
else
return false;
}
void Loading(int *result,int *