void main() //使用数组的方法,解决Josephus问题-----还没搞懂
{
const int num=20;
int interval;
int a[num];
for(int x=0;x<num;x++)
a[x]=x+1;
cout<<"please input the interval:";
cin>>interval;
for(int j=0;j<num;j++)
cout<<a[j]<<",";
cout<<endl;
int k=1;
int i=-1;
while(1)
{
for(int j=0;j<interval;)
{
i=(i+1)%num;
if(a[i]!=0)
j++;
}
if(k==num)break;
cout<<a[i]<<",";
a[i]=0;
k++;
}
cout<<"\n no."<<a[i]<<" boy's won.\n";
}