货物运输系统的环路问题

问题描述

enter image description here 这包含了问题的所有细节

我们如何打印选项数量 我们使用这个公式options = (cargo / lorrysize) + 1这给了我们很多选择 但是之后我们陷入困境 示例货物尺寸为100

100     100/30=3+1=4
option 1
30
30
30
option 2
30
30
10
10
10
option 3
10x10
option 4
30
10x7

第二个例子

150      150/30=5+1=6
option 1
30x5
option 2
30x4
10x3
option 3
30x3
10x6
option 4
30x2
10x9
option 5
30
10x12
option 6
10x15

我们尝试这样做,但是不知道如何编写“ for循环”部分的代码 我希望这足以让你们理解

#include <iostream>
#include <vector>
#include <iterator>
#include <fstream>
#include<string>
using namespace std;

/*
Steps to complete program
Step 1: Find total options available (how many Lorrys & Vans) for the input cargo capacity in .txt files
Step 2: For each option,find its:   Amount of Lorrys and Vans
                                     Total cost for both the Lorrys and Vans
                                     Find the max trip
Step 3: Find the top 3 cheapest/lowest cost trips and display
Step 4: Find the fastest available trip and display
*/

class CTS //cargo transport system
{
int i;
    int cargo,lorryprice,vanprice,lorrysize,vansize,allOps;
    //vector<double> options,lorry,vans,totalC,nooftrips;
    //vector <double>::iterator option,minilorry,cost,trips,van;

public:
    void set_cargo(int);
    void set_lorryprice(int);
    void set_vanprice(int);
    void set_lorrysize(int);
    void set_vansize(int);

};
void CTS::set_cargo(int total_cargo){
    cargo = total_cargo;
}
void CTS::set_lorryprice(int lorryP){
    lorryprice = lorryP; 
}

void CTS::set_vanprice(int vanP){
    vanprice = vanP;
}
void CTS::set_lorrysize(int lorryS){
    lorrysize = lorryS;
}
void CTS::set_vansize(int vanS)
{
    vansize = vanS;
}

int main()
{
    int cargo,options,i;
    ifstream infile;
    infile.open("size.txt");
    if(infile.is_open()){
        infile >> cargo;
        infile >> lorryprice;
        infile >> vanprice;
        infile >> lorrysize;
        infile >> vansize;
    }
 CTS run;
    run.set_cargo(cargo);
    run.set_lorryprice(lorryprice);
    run.set_vanprice(vanprice);
    run.set_lorrysize(lorrysize);
    run.set_vansize(vansize);

    infile.close();

    options = (cargo / lorrysize) + 1;
    
    
    for (i = 0; i < options; i++)
    {
       

        cout << i << " " << cargo - lorrysize << endl; // this part we need help with we have no clue




    }
    


    /*cout << cargo << endl;
    cout << lorryprice << endl;
    cout << vanprice << endl;
    cout << lorrysize << endl;
    cout << vansize << endl;*/
    return 0;
}

解决方法

一旦您拥有最多的货车数量,您可以减去货车的货物并计算剩余的货车数量,如下所示:

function onEdit(e) {
  
  var sheetsToWatch = "MAIN";
  var changelogSheetName = "LogSheet";
  var logSheet = SpreadsheetApp.getActive().getSheetByName(changelogSheetName);
  var timestamp = new Date();
  var row = e.range.getRow();
  var col = e.range.getColumn();
  var sheet = e.range.getSheet();
  var sheetName = sheet.getName();
  if(col === 4 && row > 1 && sheetsToWatch ==sheetName){
    var values = sheet.getRange(row,1,4).getValues()[0];
    logSheet.appendRow([new Date(),values[0],values[1],values[3]]);
  }     
}

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...