Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Greedy Knapsack Algorithm (code In C++)

DZone's Guide to

Greedy Knapsack Algorithm (code In C++)

· Mobile Zone
Free Resource

Download this comprehensive Mobile Testing Reference Guide to help prioritize which mobile devices and OSs to test against, brought to you in partnership with Sauce Labs.

// Greedy Knapsack


/*Greedy Knapsack Program
Source code created by S.Kaarthikeyan from 
Computer Technology And Application Department from 
Coimbatore Institute of Technology
*/

# include 

int w[10],p[10],p_no[10],n,m;
float pwr[10];

template 
void swap(T *a,int i,int j)
{
T temp;
temp=a[j];
a[j]=a[i];
a[i]=temp;
return;
}

void line()
{
coutm;
cout>n;
coutw[i];
cout>p[i];
pwr[i]=(float)p[i]/w[i];
}
display();
for(i=0;i

Analysts agree that a mix of emulators/simulators and real devices are necessary to optimize your mobile app testing - learn more in this white paper, brought to you in partnership with Sauce Labs.

Topics:
c+

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}