Today, I saw Josephus questions, suddenly I want to write some things, combined with my own thoughts, so I wrote these posts. Because there are a few code a bit long, I will be developed. If you have any help you have, I am gratifying. Maybe you will say that there is a lot of books in this question, but I am writing in different ways, so that beginners will experience the difference between the facing-oriented object; and you can also see what I wrote. And the differences in some books. If you are a prawn, you can smile, or enlighten me.
Josephus extension problem (2): A group of children enclose a circle, and the M numbers are counted in the clockwise direction. If you want the win, you will win, what kind of child wants to start from?
/ / ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /RING.H / / ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~ struct node {int code; node * next;}; class ring {public: Ring (int N); ~ Ring (); void Progress (int M); void printnode (); int getCode (); void deletenode (); Protected: node * head; node * pivot; node * pcur;}; // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~ # include
#include "ring.h" #include "jose.h" jose :: jose (int Boys, int start, int m) {ix (BOYS <1) {cout << "Bad Number of Boys! / N"; RETURN } IF (Begin <0) {cout << "Bad beginning position! / N"; return;} = ((M> <1) || (m> Boys)) {cout << "Bad Interval Number! / N "} Numofboys = BOYS; beginpos = begin; interval = m;} jose :: jose () {int BOYS, BEGIN, M; cout <<" please input the number of boys.then input the number which you want To begin count.The thirt: / n "; cin >> BOYS >> Begin >> m; IF (Boys <1) {cout <<" Bad Number of Boys! May BE, The Number IS TOO Small! / n "; return;}}} {cout <<" The value of the beginning number muşpi 1./n "; return;} = ((m <1) || (m> BOYS)) {cout << "Interval number is between 1 and number of boys"; return; numofboys = BOYS; beginpos = begin; interval = m;} int Jose :: getwinner () {RIN (Numofboys); x .Progress (beginpos-1); for (int i = 1; i