通过进栈出栈实现循环
#include<iostream>
#include<queue>
using namespace std;
queue<int> q;
int main(){
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++)
q.push(i);
int num=1;
while(!q.empty()){
if(num==m){
cout<<q.front()<<" ";
q.pop();
num=1;
}
else{
q.push(q.front());
q.pop();
num++;
}
}
return 0;
}