#include<stdio.h> #include <stdlib.h> #include <string.h> struct link { int n; struct link *next; }; struct link *creat(int n)//创造环形链表(循环) { int i; struct link *p,*q,*head=NULL; for(i=1;i<=n;i++) { p=(struct link *)malloc(sizeof(struct link)); if(head==NULL) head=p; else q->next=p; p->n=i; q=p; } p->next=head; return (head); } main() { struct link *h,*q,*r; int num; scanf("%d",&num); h=creat(num); int count=1; q=r=h; while(q->next!=r)//筛选 { if(count%3!=0) { r=q; q=q->next; } else { q=q->next; r->next=q; } count++; } printf("%d\n",q->n); }