单链表的建立 C语言实现
来源:互联网 发布:域名需要购买吗 编辑:程序博客网 时间:2024/06/14 18:30
#include <stdlib.h>#include <stdio.h>#include <malloc.h>struct LNode{int data;struct LNode *next;};//创建链表,count为创建的链表的节点数目struct LNode *create(int count){int i;struct LNode *pNode = NULL;struct LNode *pNewNode = NULL;struct LNode *head = NULL;printf("Input the integers :\n");for(i = count;i > 0;i--){pNewNode = (struct LNode*)malloc(sizeof(struct LNode));//分配节点空间scanf_s("%d",&pNewNode->data);if(head == NULL)//指定头结点{head = pNewNode;pNode = pNewNode;}else{pNode->next = pNewNode;pNode = pNewNode;}}pNode->next = NULL;return head;}//入口函数int main(){int count;//链表节点数struct LNode *node;printf("Input the count of nodes you want to create:");scanf_s("%d",&count);node = create(count);printf("The result is :\n");while(node){printf("%d",node->data);node = node->next;}system("pause");}
建立单链表的代码如下:
0 0
- 单链表的建立 C语言实现
- c语言-单链表的建立
- 单链表的建立(C语言):头插法和尾插法建立单链表
- 图的邻接矩阵的建立(C语言实现)
- C语言单链表的建立,查找,添加,删除,修改功能实现
- C语言 堆栈的建立
- C语言树的建立
- c语言之建立单链表
- c语言建立单链表及基于单链表的操作
- 单链表的C语言实现
- 单链表的C语言实现
- c语言单链表的实现
- 单链表C语言的实现
- 单链表的C语言实现
- C语言单链表的实现
- 【C语言】单链表的实现
- [c语言]单链表的实现
- 单链表的C语言实现
- PrintStream
- Tiny64开发板连接nfs,执行qt程序
- DateStream
- 基础类BaseViewController
- Permutations II -- leetcode
- 单链表的建立 C语言实现
- JAVA IO输入输出流部分代码的入门应用
- 为什么要使用Get和Set访问器
- [Codeforces] 474B - Worms
- OC通讯录
- 2015 年 JXNU_ACS 算法组寒假第一次周赛 作答总结
- opencv1.0 打开摄像头
- 覆盖拦截器栈stack中的参数值
- 基于半色调技术的图像打印程序(Image Printing Program Based on Halftoning)