int MFKnapsack( int i , int j , struct Knapsack *knapsack , struct Goods *goods ) { int value ; if(i==0) return 0 ; else { if(T[i][j]<0) { if( j<goods->weight[i] ) value = MFKnapsack(i-1,j, knapsack , goods ) ; else value = Max( MFKnapsack(i-1,j, knapsack , goods ) , goods->value[i]+MFKnapsack( i-1 , j-goods->weight[i] , knapsack , goods ) ); T[i][j] = value ; } return T[i][j] ; } }