queue库好用!
#include<iostream>
#include<queue>
using namespace std;
int main()
{
queue<int> q;
int n; //n为报数总人数,m为报数号,1~m
cin >> n;
for(int i = 1;i<=n;i++)
{
q.push(i);
}
int count = 0;
while(q.size() > 1)
{
count ++;
int front = q.front();
q.pop();
if(count == 3)
count = 0;
else
q.push(front);
}
cout << q.front() << endl;
return 0;
}