#include<stdio.h> #include<stdlib.h> typedef struct Node { int data; struct Node* next; }Node; Node * CreateList(int count) { int data; Node *head = (Node *)malloc(sizeof(Node)); Node *rear; head->next=NULL; rear=head; for (int i = 0; i < count; i++) { Node *p = (Node *)malloc(sizeof(Node)); scanf("%d",&data); p->data=data; printf("已存入%d\n",p->data); p->next=head->next; rear->next=p; rear=p; } free(head); return rear->next; } int main() { int count; int i=0; scanf("%d",&count); Node *p=CreateList(count); while (p!=p->next) { i++; if ((i+1)%3==0) { Node *temp; temp=p->next; p->next=temp->next; printf("当前是第%d个数,被移除的数是%d\n",i+1,temp->data); free(temp); } else p=p->next; } printf("现在是第%d位,剩下的数是%d\n",i+2,p->data); return 0; }