回复 10楼 wylzjcw
你不觉得跟你5楼的解释矛盾吗?

我就是真命天子,顺我者生,逆我者死!









程序代码:#include<stdio.h>
#include<malloc.h>
#include<stdlib.h>
struct M
{
int num;
struct M *next;
};
int main(void)
{
int i, j, n, t;
struct M *p, *q, *head,*w;
p = (struct M*)malloc(sizeof(struct M));
printf("The number of monkeys: ");
scanf("%d", &n);
printf("The amount of count: ");
scanf("%d", &t);
for(i = 1;i <= n;i++)
{
q = (struct M*)malloc(sizeof(struct M));
q->num = i;
if(i == 1) head = q;
p->next = q;
p = q;
}
p->next = head;
p = head;
w=head;
for(i = 0;i <= n-2;i++)
{
for(j = 0;j <= t-1;j++)
{
q = p;
p = p->next;
if(w->next!=q&&w!=q)w=w->next;
}
w->next = p;
}
printf("The king: %d\n", p->num);
getch();
return 0;
}
