Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- std::cout << "Przedmioty w plecaku: " << std::endl;
- for (int i = items; i >= 1; i--)
- {
- if (arrayWithCopiedValue[i - 1].value <= opt)
- {
- int weight = arrayWithCopiedValue[i - 1].weight + tableForApprox[i - 1][opt - arrayWithCopiedValue[i - 1].value];
- weight = weight < 0 ? INT_MAX : weight;
- if (weight < tableForApprox[i - 1][opt])
- {
- opt -= arrayWithCopiedValue[i - 1].value;
- std::cout << "Wartosc: " << allItems[i - 1].value << " waga: " << allItems[i - 1].weight<< std::endl;
- totalWeight += allItems[i - 1].weight;
- returnedResult += allItems[i - 1].value;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement