输入n个正整数(代表n个人),围成一圈,按1,2,3报数,报到3的人跳出。问最后一个留在圈中的人是谁

输入n个正整数(代表n个人),围成一圈,按1,2,3报数,报到3的人跳出。试编一个程序,问最后一个留在圈中的人是谁?
c语言编程,求教,谢谢
我需要编写的程序~~~
不会写啊~~~
谢谢赐教

int a[n];
for(int i=0;i<n;i++)
a[n]=1;
int j,shu,x=0;
for (i=1;i<=n-1;i++)
{
shu=1;
while (shu<=3)//数数
if (a[x]==1){x++;shu++;if (shu==4) a[x-1]=0;}
else x++;
if (x==n) x=0;
}
for(i=0;i<n-1;i++)
if (a[i]==1) cou<<i;
大概是这样的
温馨提示:答案为网友推荐,仅供参考
第1个回答  2007-11-20
好像哪本书上有
第2个回答  2007-11-20
最后剩一个人是第一个人
相似回答