单向循环链表的建立
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);
}
#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);
}
相关文章推荐
- 数据结构作业代码保存-2.1 单向循环链表的建立,插入和删除,和指针移动
- 单向循环链表
- c语言实现--单向循环链表操作
- 建立有序双向循环链表
- 如何判断一个单向链表是否存在循环的经典方法
- 编写算法实现建立一个带头结点的含n个元素的双向循环链表H,并在链表H中的第i个位置插入一个元素e
- 【学习总结】循环链表模拟约瑟夫问题和循环链表的初始化、建立、删除(按值与按位置)
- 单向链表中循环的查找方法总结
- 数据结构--单向循环链表、双向循环链表
- 链表(单链表,带表头的链表,单向循环链表,双向循环链表)
- 单向链表建立 排序
- 带表头的单向循环链表
- 单向循环链表的C++实现
- 单向循环链表的简单实现
- 单向循环链表简单应用
- 单向循环链表的实现
- 大话数据结构(三)——单向循环链表的java实现
- C++建立单向链表链表头指针需要使用指针类型的引用参数?
- <8> 单向循环链表在一些场景下的应用