# Include
Struct Bag {int BagID; int BagWeight; int BagPrice; int SinglePrice; float Num ;}; void seekBest (Bag bag [], int n, float bagRL) {int I; float PCIe = bagRL; for (I = 0; I
PCIe) break; else {bag [I]. num = 1; PCIe = PCIe-bag [I]. bagWeight ;}}if (I <= n) {bag [I]. num = WAV/bag [I]. bagWeight;} for (I = 0; I
0) {printf ("% f items with ID: % d weight: % d !!! \ N ", bag [I]. bagID, bag [I]. bagWeight, bag [I]. num) ;}} void Sort (Bag bag [], int n) {int j; Bag temp; int I; for (I = 0; I
# Include
# Define N 50 struct Object {int list; // Object ID float p; // Object Value float w; // Object weight float v; // Object value/weight ratio}; void MERGE (Object A [], int low, int mid, int high) {int h, I, j, k; object * B = (Object *) malloc (high-low + 1) * sizeof (Object); h = low; I = 0; j = mid + 1; while (h <= mid & j <= high) {if (A [h]. v> = A [j]. v) {B [I] = A [h]; h = h + 1;} else {B [I] = A [j]; j = j + 1 ;} I ++;} if (h> mid) {for (k = j; k <= high; k ++) {B [I] = A [k]; I = I + 1 ;}} else for (k = h; k <= mid; k ++) {B [I] = A [k]; I = I + 1;} I = 0; for (k = low; k <= high; k ++) {A [k] = B [I]; I ++;} free (B);} void MERGESORT (Object array [], int low, int high) {int mid; if (low
> M; cout <"Enter the number of objects:"; cin> n; cout <"Enter the object price and weight:" <
> Instance [I]. p> instance [I]. w; cout <"--------------------------------------" <