# include<iostream.h>//josephus问题
void main()
{
int *array;
int arraysize,interval;
cout<<"please input arraysize and interval:\n";
cin>>arraysize>>interval;
if((array=new int[arraysize])==NULL)
{
for(int i=0;i<arraysize;i++)
array[i]=i+1;
for(i=0;i<arraysize;i++)
cout<<array[i]<<' ';
}
josephus(array,interval,arraysize);//.cpp(16) : error C2065: 'josephus' : undeclared identifier
}
void josephus(int* Array,int Interval,int Arraysize)//cpp(21) : error C2373: 'josephus' : redefinition;
{ //different type modifiers
int i=-1;
int k=1;
while(1)
{
for(int j=0;j<Interval;)
{
i=(i+1)%Arraysize;
if(Array[i]!=0)
j++;
}
if(k==Arraysize) break;
cout<<Array[i]<<' ';
Array[i]=0;
k++;
}
cout<<Array[i];
}