Home > Back-end >  Joseph problem (one dimensional array)
Joseph problem (one dimensional array)

Time:09-19

15 christians and 15 pagan in distress at sea, half of them must be put into the sea, and the rest of the people can survive, so want to have an idea: 30 people round into a circle, from the first man began to sound off, every count to 9 people will he throw into the sea, so until only 15 people, asked what method, can make each into the sea are heretics,
Tip: (1) 30 people order number, since the incremental k number off, 9 k %==0, the man into the sea, into the sea symbol for array element value is zero (or 1), into the sea of the people no longer count off, program output requirements: after the program is run, according to the original order, each time into the sea of information and the order of the remaining people

Final experiment report, a great god answers, hope that the caption program step, urgent seek urgent!!!!!!

CodePudding user response:

Online there are a lot of examples and code, it is suggested that his first search, test
  • Related