PROGRAM 6 Knapsack Dynamic
PROGRAM 6 Knapsack Dynamic
Design and implement C/C++ Program to solve 0/1 Knapsack problem using
#include <stdio.h>
int value;
if (v[i][j] < 0) {
if (j < w[i])
else
v[i][j] = value;
return (v[i][j]);
void main() {
scanf("%d", &n);
scanf("%d", &cap);
if ((i == 0) || (j == 0))
v[i][j] = 0;
else
v[i][j] = -1;
i = n;
j = cap;
while (j != 0 && i != 0) {
j = j - w[i];
i--;
printf("Sl.no\tweight\tprofit\n");
if (x[i]) {
}
// Output the total profit