请问各位约瑟夫循环队列接下来的代码怎么写!谢谢各位!我真的头秃了!
其实不用队列,我这有个代码,可以参考一下
#include<iostream>
using namespace std;
int main()
{
int n,m,t=0;
cin>>n>>m;
bool *a=new bool[n];//是否在圈里
for(int i=0;i<n;i++)
a[i]=true;
for(int i=0;i<n;i++)
{
for(int j=0;j<m;t++)
{
if(t>=n)
{
t-=n;
}
if(a[t])
{
j++;
}
}
a[--t]=false;
cout<<t+1<<' ';
}
return 0;
}