标签:约瑟夫环
void JosephCycle(PLinkList* ppList, int k)
{
Node* begin = *ppList;
if (*ppList == NULL)
{
return;
}
while(1)
{
Node* del;
int x = k;
// 只有一个节点的退出
if (begin->next == begin)
{
break;
}
while(--x)
{
begin = begin->next;
}
printf("%d,", begin->data);
begin->data = begin->next->data;
del = begin->next;
begin->next = del->next;
free(del);
}
标签:约瑟夫环
原文地址:http://10622551.blog.51cto.com/10612551/1688213