单向循环链表的创建
#include<stdio.h> #include<stdlib.h> #define null 0 typedef struct node { int number; struct node *next; }student; main() { student *head,*p,*temp; int i; //建立链表头 //head=p=(student*)malloc(sizeof(student));//分配地址 head->number=1; head->next=NULL; // for(i=2;i<16;i++) { temp=(student*)malloc(sizeof(student)); temp->number=i; temp->next=temp; head->next=temp; head=temp; //head->next; } head->next=p; while(p!=p->next) { p->next->next=p->next->next->next; p=p->next->next; } printf("%d\n",p->number); }