您的位置:首页 > 其它

单向循环链表的建立

2011-02-11 21:42 302 查看
#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);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: