This program solves the bin packing problem, where objects of various weights need to be packed into containers, with each container having a maximum weight capacity of 10 pounds. The algorithm used here places objects with the largest weight into the first available bin where they fit.
-
Run the program and enter the total number of objects you want to pack.
-
Enter the weight of each object, separated by spaces.
-
The program will calculate the number of containers needed to pack all the objects and display the contents of each container.
Here is a sample run of the program:
Enter the number of objects: 6 Enter the weights of the objects: 7 5 2 3 5 8
Container 1 contains objects with weight 8 2 Container 2 contains objects with weight 7 3 Container 3 contains objects with weight 5