#include<iostream>
#define MAX 20
using namespace std;
int Queen(int x,int y)
{
int q[MAX],i=0,z=0;
for(i=0;i<x;++i)
q[i]=i+1;
//while(z!=(x-1)*y)
//
{
for(i=0;i<x;++i)
{
if(q[i]!=0)
{
z=z+1;
}
/*
else
{
continue;
}*/
//if(z==(x-1)*y)
//
break;
if(z/y==0)
{
q[i]=0;
}
if(z==(x-1)*y)
break;
else
{
continue;
}
}
//
}
for(i=0;i<x;++i)
{
if(q[i]!=0)
cout<<"猴子大王的编号是:"<<q[i]<<endl;
}
return 0;
}
int main()
{
int m,n;
cout<<"请输入猴子的个数和要截止的数"<<endl;
//cin>>m>>n>>endl;
scanf("%d,%d",&m,&n);
Queen(m,n);
return 0;
}
试了n次,就是与目标不同!