C语言版:
#include<stdio.h>
#include<stdlib.h>
int main (int argc, char **argv)
{
int n,i,j,k,c;
int *p;
k=0;
printf("please enter the number of the people:");
scanf("%d",&n);
p = (int *)malloc(n*sizeof(int));
for(i=1;i<=n;i++)
*(p+i)=i;
i = 1;
for(j=0;j<n-1;)
{
if(*(p+i)!=0)
k++;
if(k==3)
{
*(p+i)=0;
j++;
k=0;
}
i++;
if(i==(n+1))
i=1;
}
p++;
while(*p == 0)
{
p++;
}
printf("%d\n",*p);
system("pause");
return 0;
}