DAA1314
DAA1314
Dijkstra’s Algorithm
Input:-
#include <iostream>
using namespace std;
#include <limits.h>
#define V 9
return min_index;
}
Input:-
#include <iostream>
#include <algorithm>
#include <vector>
return total_value;
}
int main()
{
cout << "Enter the weights of the items, press -1 to stop" << endl;
while(true)
{
int weight;
cin >> weight;
if(weight == -1)
break;
weights.push_back(weight);
}
cout << "Enter the values of each item, press -1 to stop" << endl;
while(true)
{
int value;
cin >> value;
if(value == -1)
break;
values.push_back(value);
}
int capacity;
cin >> capacity;
cout << "The maximum value possible based on current list is: " << fractional_knapsack(weights, values, capacity)
<< endl;
}
Output:-