An ancient puzzle concerns a ship caught in a terrible storm. Although there were 30 passengers on board, the lifeboats would only hold fifteen. So as not to leave anybody behind, the captain resolved to throw half the passengers overboard before taking to the lifeboats (nice guy, huh?).
As it happens, exactly fifteen of the passengers had slighted the captain by not dining at the Captain&'s Table during the cruise (isn&'t that coincidental?). The captain, in revenge, arranged all the passengers in a circle, and began to count, throwing every nth passenger overboard. As you might imagine, only the passengers he disliked vanished beneath the waves. The captain&'s fifteen dinner compamons were able to use the lifeboats, and the Captain went down with the ship.
What was the number n? Select an appropriate data structure to simulate the counting process, and find which number n yields the proper result. (Hint: it&'s less than
30) The diagram illustrates the starting order of the passengers - the Xs go overboard, the Os take the lifeboats. The arrow indicates where to start the count.
O O O O O X X X X O O X X O X O O X O X O X X O X X O O X X
//drawn in circle as in a circular linked list
Your program should sequence through the possible values for n and print out the order of passengers being thrown overboard for each value. (The first passenger, the one the arrow is pointing to, is passenger #1.) Stop at the lowest value that matches the sequence described by the diagram and print an appropriate message (or if no value of n works, print a message saying that). Of course you should use good programming technique, so that if a different number of passengers was involved, in a different order, the changes to your program would be minimal. You MUST use a dynamically allocated linked data structure. Your data structure MUST be implemented as a class with appropriate class functions. Be sure to think about what is a class function (associated with th
## Deliverables
1) Complete and fully-functional working program(s) in executable form as well as complete source code of all work done.
2) Installation package that will install the software (in ready-to-run condition) on the platform(s) specified in this bid request.
3) Complete ownership and distribution copyrights to all work purchased.
## Platform
MS Visual c++
WIndows XP