单向循环链表的建立

#include
#include
#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 = NULL;
  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);
}

你可能感兴趣的:(程序=算法+数据结构)