#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 = 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);
}
单向循环链表的建立
最新推荐文章于 2024-08-20 17:02:31 发布