You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
1.2 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include<iostream>
using namespace std;
const int N = 610;
int a[N];
int main() {
//n:总人数,s本轮已计数人数p:现在检查的是第几个人
int n, s = 0, p = 0;
cin >> n;
//一共需要出圈次数n-1次,最终需要剩下一个人
for (int i = 1; i <= n - 1; i++) {
//如果本轮没有达到三个人点数的情况下,就一直在想办法找三个人
while (s < 3) {
if (p == n)p = 0; //如果走到了最后一个需要把p的位置调整为虚拟的0号位置这个是难点不好想
p++; //不管是不是有效的数字是不是出过列我就是要往前一直走我就是个指针我的作用是当找到第3个人的时候这个人的下村是多少。
if (a[p] == 0) s++; //只有标识为0的才能查数是1的表示已经出列不能查数
}
//找到数3的了
a[p] = 1; //把这个位置标识为已经出列了
s = 0; //本轮S的任务完成清零让下次查数有个好的计数器
}
for (int i = 1; i <= n; i++) if (a[i] == 0)cout << i;//输出没有出列的人
return 0;
}