回顾数据结构(2):单循环链表
2016-11-05 13:35
253 查看
#include <stdio.h> #include<stdlib.h> #include<malloc.h> typedef struct LNode{ int data; struct LNode *next; }Node,*LinkList; //创建循环链表 int createLinkList(LinkList &L,int length){ LinkList head,p; L = (LinkList)malloc(sizeof(Node)); if(!L){ printf("malloc action error"); return 0; } L->next = L; head = L; int j=0; for(;j<length;j++){ p = (LinkList)malloc(sizeof(Node)); if(!p){ printf("malloc action error"); return 0; } scanf("%d",&p->data); p->next = head->next; head->next = p; head = p; } return 1; } int printfLinkList(LinkList L){ LinkList head; head = L->next; while(head!=L){ printf("%d ",head->data); head = head->next; } return 1; } int main() { LinkList L; int length; printf("please input the LinkList length\n"); scanf("%d",&length); createLinkList(L,length); printf("printf the LinkList \n"); printfLinkList(L); }
相关文章推荐
- ※数据结构※→☆线性表结构(list)☆============单向循环链表 链式存储结构(list circular single)(四)
- 数据结构之循环链表
- 数据结构--双向循环链表--插入
- C++实现数据结构三 双向循环链表
- C语言数据结构之判断循环链表空与满
- 数据结构学习系列三-单向循环链表(c++实现且应用模板)
- C语言实现数据结构中的循环链表
- 数据结构Java实现04----循环链表、仿真链表
- C/C++、JAVA 数据结构 :双向循环链表
- 《Delphi 算法与数据结构》学习与感悟[9]: 循环链表
- 数据结构 循环链表之约瑟夫问题
- 数据结构高分笔记 算法2-18~2-19:双向循环链表
- 数据结构之循环链表
- 重温数据结构:有序循环链表的插入
- 数据结构_线性表_链式存储_单向循环链表的基本操作
- 数据结构的C实现_双向循环链表
- 数据结构Java实现04----循环链表、仿真链表
- 数据结构之设置尾指针的单向循环链表(参考整理严蔚敏数据结构)
- 数据结构Java实现 ----循环链表、仿真链表
- ※数据结构※→☆线性表结构(list)☆============单向循环链表结构(list circular single)(四)