I am fairly new to C++. I have implemented the fractional knapsack problem in c++ for the course “Algorithmic Toolbox” on Coursera: #include <iostream> #include <iomanip> using namespace std; int get_max_index(double A[], double B[],int l) { /* int A = array of value int B = array of weights int l = length of the […]

Categories

## Stack Overflow for Fractional Knapsack

- Post author By Full Stack
- Post date March 13, 2020
- No Comments on Stack Overflow for Fractional Knapsack

- Tags "w", double? b, I am fairly new to C++. I have implemented the fractional knapsack problem in c++ for the course "Algorithmic Toolbox" on Coursera: #include, int l) { /* int A = array of value int B = array of weights int l = length of the array */ int p, loot{0}; for(int i=0;i> values[i] >> weights[i]; } for(int j=0;j<n;j++) { if(W==0){break;}, max(0, Max{0}; for(int j=0;j Max){Max = A[j]/B[j];p = j;} } return p; } int main() { int n, n); if(weights[q] <= W){W1 = weights[q];} else{W1 = W;} loot += W1 * (values[q]/weights[q]);, Q, W1{0}; cin >> n >> W; double values[n], weights, weights[n]