#include < conio.h >
#include < iostream.h >
class knapsack
{
int n,m,*p,*w;
float *x,*pw;
public:
knapsack()
{
clrscr();
cout<<"\n\t\tKNAPSACK PROBLEM\n";
int i;
cout<<"\nEnter the number of objects : ";
cin>>n;
p=new int[n];
w=new int[n];
pw=new float[n];
x=new float[n];
for(i=0;i>m;
cout<<"\nEnter the profit of the elements : ";
for(i=0;i>p[i];
cout<<"\nEnter the weights of the objects : ";
for(i=0;i>w[i];
for(i=0;iv)
break;
else
{
x[i]=1.0;
v=v-w[i];
}
}
if(i
Free C programs with output, c programming language, object oriented programming, c programs codes, c program shortcuts, history of c programming language, c programming compilers
ad
Sunday, 8 February 2015
program to implement fractional knapsack problem using greedy method in cpp
//program to implement knapsack problem using greedy method
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment