装船问题
int mian() { int n; struct Node { double price,weight; double rat; }node[111]; double maxPrice =0; double maxCarryweight=0;double nowCarryweight=0; int t=0; for(int i=0;i<n;i++) { if(nowCarryweight+node[i].weight<maxCarryweight) //可以装下整个货物 { nowCarryweight+=node[i].weight; maxPrice+=node[i].price; t=i; } } if(nowCarryweight<maxCarryweight) //还有空间,但是装不下一整个 { maxPrice+=(maxCarryweight-nowCarryweight)*node[t].rat; } return 0; }