////////////////////////////////////////////////////////////////////////////////////////////////// // This program is designed by : Ne'matollah Kamalfar & shahin Noormah // // professor: Mrs. Tadayon // // Knapsack Algorithm // // compiled by Borland C++ 5 // ////////////////////////////////////////////////////////////////////////////////////////////////// #include #include struct knapsack { int n; int* w; int* p; int* itemNum; }s; void Knapsack(int capacity,knapsack& ksack) { int i; float* value=new float[capacity]; ksack.itemNum=new int(ksack.n); for(i=0;icapacity) break; value[i]=1.0; capacity=capacity-ksack.w[i]; maxprofit+=ksack.p[i]; cout<<"\n "<>N; s.n=N; s.w=new int [N]; s.p=new int [N]; cout<<"Enter Maximum capacity of Knapsack: "; cin>>W; cout<<"\nPlease Enter"; cout<<"\n"; for(int i=0;i>s.p[i]; cout<<"\nItem"<< (i+1) <<" weight: "; cin>>s.w[i]; cout<<"\n" ; }//for Knapsack(W,s); getch(); }//main