Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1.     std::cout << "Przedmioty w plecaku: " << std::endl;
  2.    
  3.     for (int i = items; i >= 1; i--)
  4.     {
  5.         if (arrayWithCopiedValue[i - 1].value <= opt)
  6.         {
  7.             int weight = arrayWithCopiedValue[i - 1].weight + tableForApprox[i - 1][opt - arrayWithCopiedValue[i - 1].value];
  8.             weight = weight < 0 ? INT_MAX : weight;
  9.             if (weight < tableForApprox[i - 1][opt])
  10.             {
  11.                 opt -= arrayWithCopiedValue[i - 1].value;
  12.  
  13.                     std::cout << "Wartosc: " << allItems[i - 1].value << " waga: " << allItems[i - 1].weight<< std::endl;
  14.                     totalWeight += allItems[i - 1].weight;
  15.                     returnedResult += allItems[i - 1].value;
  16.  
  17.             }
  18.         }
  19.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement