当前位置:网站首页>Creation of single linked list
Creation of single linked list
2022-07-18 07:06:00 【Smile Hun】
Definition of structure
struct LinkNode
{
int element;
LinkNode* next;
};
Complete the definition of the structure , You need to include the Elements , And point to the next structure The pointer .
This structure can be seen as containing two properties , One is the element that needs to be saved (int element), The other part is the pointer to the next element (Linknode* next),p->next Call the pointer property of the structure , It can be modified .
Generation of linked list
- Create isolated nodes
p = new LinkNode();
p->element=x;// If it's worth , use . If it's an address , use ->;
- Dot the knot behind the previous node
while (x != -1) {
p = new LinkNode();
p->element=x;// If it's worth , use . If it's an address , use ->;
p->next = head->next;
head->next = p; // take p Give this pointer to head Of next, send head Of next Points to the first element of the list ; head->next Be similar to pos.x call head Medium next attribute ;
printf("Please enter a number:");
scanf_s("%d", &x);
}
Access to linked list
p = head;
while (p->next != NULL) {
printf("%d\t", p->next->element);// p In the next structure of element Elements
p=p->next;
}
边栏推荐
- LDR9201音频数字解码DAC加LDR6023C数字加PD快充方案
- About some string related functions, memory functions and some simulations
- markdown学习笔记 第二章 基本语法 (markdown编辑器下显示)
- 唐门暗器之私有云排名
- 2021年全国职业院校技能大赛(中职组)网络安全竞赛试题(9)思路
- 1-first knowledge of FPGA
- 自增(自减)运算符的运算优先级
- Dix règles d'optimisation pour clickhouse SQL
- Markdown learning notes Chapter 2 basic grammar (displayed in non markdown editor)
- 【面试必刷101】哈希
猜你喜欢
随机推荐
Private cloud ranking of Tangmen concealed weapons
Excel导入导出注解通用版
什么是进制?
【面试必刷101】哈希
用C的数组实现矩阵的加减乘与求转置
Typec display solution Daquan ldr6290 single C-Port desktop display solution
MySQL MySQL Foundation
布尔代数值
H264 decoding sequence display sequence reference sequence
开源小工具记录
YYS鼠标连点器
(1) Matlab Basics
Notes on custom types such as structs, enumerations, unions, etc
MySQL autoincrement, index, foreign key, other operations
Latest idea reset method
Pd-qc-afc multi protocol decoy chip "ldr6328s"
Thumbnailator 图片处理类库
[interview must brush 101] hash
Type-C charging OTG chip (ldr6028s)
带图像识别的YYS连点器 V2.0








