当前位置:网站首页>Double linked list -- tail interpolation construction (C language)
Double linked list -- tail interpolation construction (C language)
2022-06-26 07:52:00 【Don't hit me, it hurts!】
#include <stdio.h>
#include <stdlib.h>
// Parameter description :data Store the data
// prior Pointer to direct precursor
// next Pointer to the successor node
typedef struct DNode
{
int data;
DNode *prior;
DNode *next ;
}DNode;
void create_tail_DLinklist(DNode *&head)// Using tail interpolation method to build double linked list
{
head = (DNode*)malloc(sizeof(DNode) );
head->data = 0 ;
head->prior= NULL ;
head->next = NULL ;// Create a header node
DNode * p = head; // Point to the head node
int n;
printf(" Please enter the length of the double linked list :");
scanf("%d",&n);
while(n--)
{
DNode* q = (DNode*)malloc(sizeof(DNode));
scanf("%d",&q->data);
q->next = NULL ; // Can not write q->next = head->next; otherwise , It's a dead cycle ?
q->prior = p;
p->next = q ;
p = q ;
}
}
void Print_DLinklist(DNode *&head)
{
DNode * p = head ;
DNode * q = NULL ;
p = p->next ;
while (p != NULL)
{
printf("%d ",p->data); // Output from front to back
q = p ;
p = p->next ;
}
}
int main()
{
DNode * head ;
create_tail_DLinklist(head);
Print_DLinklist(head);
return 0;
}
Running results :

边栏推荐
- How to quickly merge multiple PDF files?
- Google Earth engine (GEE) 01- the prompt shortcut ctrl+space cannot be used
- How MySQL implements the RC transaction isolation level
- What is the difference between bone conduction earphones and ordinary earphones? Advantages of bone conduction earphones
- The first multi platform webcast of 2021ccf award ceremony pays tribute to the winners! CCF outstanding engineer
- Google Earth Engine(GEE) 02-基本了解和学习资源
- Flower instruction WP
- Project management learning
- Uni app is similar to Taobao in selecting multiple specifications of commodities (inventory judgment)
- Seven important reasons for responsive Web Design
猜你喜欢

解决 psycopg2.NotSupportedError: PQconninfo not available in libpq < 9.3

Data governance: from top project to data culture!

Redis (4) -- Talking about integer set

Seven important reasons for responsive Web Design

Redis(5)----浅谈压缩列表

Solve psycopg2 NotSupportedError: PQconninfo not available in libpq < 9.3

What are the key points of turnover box management in warehouse management

Apache inlong graduated as a top-level project with a million billion level data stream processing capability!

The first screen time, you said you optimized it, then you calculated it and showed it to me!

Important reference indicators for data center disaster recovery: RTO and RPO
随机推荐
[UVM practice] Chapter 3: UVM Fundamentals (3) field automation mechanism
Jemter stress test - basic requirements - [teaching]
信息学奥赛一本通 1355:字符串匹配问题(strs)
2021 project improvement
Hand drawn style chart library chart Implementation principle of xkcd
ReW_p
[UVM basics] TLM common data receiving and sending and data receiving examples
Mxnet implementation of network in Nin network
Real machine debugging of uniapp custom base
Jmeter压力测试-Web代理本地接口测试【教学篇】
Exploration and practice of incremental data Lake in station B
Chapter 9 (using classes and objects)
buuresevewp
Deeply analyze storage costs and find cost reduction solutions
In interface testing, several methods to verify the success of deleting interfaces
The long path of Xiao Sha (graph theory, Euler diagram)
Flower instruction WP
45. jumping game II dynamic planning DP
Livevideostackcon | evolution of streaming media distribution for online education business
What is Wi Fi 6 (802.11ax)? Why is Wi Fi 6 important?