Josephus.h class Josephus { public: void OutControl(int num,int begin,int interval). protected: int num. int begin. int interval. }.
List.h struct People { int number. People *next. }.
class List { public: List (int num)//初始化point->number { josephus = new People[num]. point = josephus. for(int i=1.i<=num.i ) { point->number = i . point->next = josephus i % num. /*利用 1取模的方式设置节点的next指针, 当到最后的时候自动指向到第一个,形成环链 */ point = point->next. } point = &.josephus[num-1]. //把起始指针设置在最后一个节点,当进入循环的时候就会从0开始, }