Tuesday, 10 September 2013

how to fill different gallons with water? [on hold]

how to fill different gallons with water? [on hold]

I have a problem of algorithm, that is: Write a program to solve the
following problem: You have two jugs: a 4-gallon jug and a 3-gallon jug.
Neither of the jugs have markings on them. There is a pump that can be
used to fill the jugs with water. How can you get exactly two gallons of
water in the 4-gallon jug? I don't know how to solve it. And it has a
generalize version that is: Generalize the problem above so that the
parameters to your solution include the sizes of each jug and the final
amount of water to be left in the larger jug. I don't know how to solve
such a problem, thank you for your help!

No comments:

Post a Comment