#include<stdio.h>
int main()
{
int i=0,n=0,m=0,out=0,num=0,a[1024]={0};
printf("the number of people:");
scanf("%d",&n);
printf("the lucky number is:");
scanf("%d",&m);
for(i=0;i<n;i++)
a[i]=1;
i=0;
while(out!=n-1)
{
if(a[i]==1)
num++;
if(num==m)
{
a[i]=0;
num=0;
out++;
}
i++;
if(i==n)
i=0;
}
i=0;
for(i=0;i<n;i++)
{
if(a[i]==1)
{
printf("Output:\nthe lucky one's number is %d\n", i);
break;
}
}
return 0;
}
终于想出来了!