64,654
社区成员
发帖
与我相关
我的任务
分享
//x表示箱子是否装0--不装 1-装
//w表示箱子重量
//c表示船的载重量
//n表箱子个数
void Loading(int x[], Type w[], Type c, int n)
{
int *t = new int [n+1];
Sort(w, t, n);
for (int i = 1; i <= n; i++)
x[i] = 0;
for (int i = 1; i <= n && w[t[i]] <= c; i++)
{
x[t[i]] = 1;
c -= w[t[i]];
}
}