Akdora’s Blog

Programming, Oracle, Life, Fun

SubSet Sum Problem Example in C January 10, 2007

Filed under: C & C++ — Akdora @ 5:32 pm
Tags: , , ,

In this assignment, you will write a program that will fill 3 boxes with fruits. Your program will get the fruits’ names, their weights and the capacities of the boxes from a file. You can get the file from the link :






  •  The program will attempt to fill these boxes with fruits one by one, starting from the first (Box1) and continuing with the next (e.g. Box2) until to the last (e.g. Box3) based on the following criteria:
    • Either a box can be filled with the exact weight (ex. Box1 should get exactly 32 kg fruits)., or it will be skipped and left empty and the next box will be tried to be filled.
    • Program will not use same fruit twice. (ex. If program have used apple for Box1, apple can’t be used again for next boxes).
  •  Program will write each boxes’ last situations to the result.txt file. If a box is full, the names of the fruits that are in that box must be written to the result.txt. If the box is empty, “Box-id: empty” must be written to the result.txt. Output file should look like as follows, note that following is sample output not the solution:

Box1: lemon, mango, …

Box2: empty

Box3: apple, …

solution in C:


One Response to “SubSet Sum Problem Example in C”

  1. This is great. Really nice post. Very Informative and helpful post.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s