
#include <cstdlib>
#include <iostream>
using namespace std;
void knapsack(int n, float weight[], float profit[], float capacity)
{
float x[20], tp= 0;
int i, j;
float u=capacity;
for (i=0;i<n;i++)
x[i]=0.0;
for (i=0;i<n;i++)
{
if(weight[i]>u)
break;
else
{
x[i]=1.0;
tp= tp+profit[i];
...