int n = 5,m = 4;//人数,报的数(3)
int a[5] = {0};//每个人的状态
int count = 0;//目前出圈的人数
int number = 1;//当前报的数
int i = 0;//下标
while (count < 5) {
if (a[i] == 0) {
if (number != m) {
number++;
i++;
if (i >= n) {
i = 0;
}
} else {
a[i] = 1;
number = 1;
printf("%d\n",i);
count++;
i++;
if (i >= n) {
i = 0;
}
}
} else {
i++;
if (i >= n){
i = 0;
}
}
}