#define _CRT_SECURE_NO_WARNINGS 1 #include<stdio.h> #include<stdlib.h> typedef int Elemtype; //定义双线链表 typedef struct node { Elemtype data; struct node* next; struct node* prev; }dNode; //初始化双链表 dNode* initlist() { dNode* head = (dNode*)malloc(sizeof(dNode*)); head->data = 0; head->next = NULL; head->prev = NULL; return head; } //头插法-双向链表 int inserthead(dNode* head, Elemtype e) { dNode* P = (dNode*)malloc(sizeof(dNode*)); P->data = e; P->prev = head; P->next = head->next; if (head->next != NULL) { head->next->prev = P; } head->next = P; return 1; } //遍历双向链表 void listdNode(dNode* List) { dNode* P = List->next; while (P != NULL) { printf("%d ", P->data); P = P->next; } printf("\n"); } //尾插法-双向链表 dNode* findtail(dNode* L) { dNode* P = L; while (P->next != NULL) { P = P->next; } return P; } dNode* insertTail(dNode* tail, Elemtype e) { dNode* New = (dNode*)malloc(sizeof(dNode)); New->data = e; New->next = NULL; New->prev = tail; tail->next = New; return New; } //指定位置插入数据 int insertNode(dNode* L, int pos, Elemtype e) { dNode* P = L; int i = 0; while (i < pos - 1) { P = P->next; i++; if (P == NULL) { return 0; } } dNode* Q = (dNode*)malloc(sizeof(dNode)); Q->data = e; Q->prev = P; Q->next = P->next; P->next->prev = Q; P->next = Q; return 1; } //指定位置删除数据 int deleteNode(dNode* L, int pos) { dNode* P = L; int i = 0; while (i < pos - 1) { P = P->next; i++; if (P == NULL) { return 0; } } if (P->next = NULL) { printf("要删除的位置错位\n"); return 0; } dNode* Q = P->next; P->next = Q->next; Q->next->prev = P; free(Q); return 1; } //释放双向链表 dNode* freedNode(dNode* L) { dNode* P = L->next; dNode* Q; while (P != NULL) { Q = P->next; free(P); P = Q; } L->next = NULL; } int main() { dNode* dlist = initlist(); inserthead(dlist, 3); inserthead(dlist, 4); inserthead(dlist, 6); inserthead(dlist, 7); inserthead(dlist, 10); inserthead(dlist, 19); inserthead(dlist, 26); listdNode(dlist); dNode* tail = findtail(dlist); tail = insertTail(tail, 2007); listdNode(dlist); insertNode(dlist, 2, 0); listdNode(dlist); deleteNode(dlist, 2); listdNode(dlist); }#define _CRT_SECURE_NO_WARNINGS 1 #include<stdio.h> #include<stdlib.h> typedef int Elemtype; //定义双线链表 typedef struct node { Elemtype data; struct node* next; struct node* prev; }dNode; //初始化双链表 dNode* initlist() { dNode* head = (dNode*)malloc(sizeof(dNode*)); head->data = 0; head->next = NULL; head->prev = NULL; return head; } //头插法-双向链表 int inserthead(dNode* head, Elemtype e) { dNode* P = (dNode*)malloc(sizeof(dNode*)); P->data = e; P->prev = head; P->next = head->next; if (head->next != NULL) { head->next->prev = P; } head->next = P; return 1; } //遍历双向链表 void listdNode(dNode* List) { dNode* P = List->next; while (P != NULL) { printf("%d ", P->data); P = P->next; } printf("\n"); } //尾插法-双向链表 dNode* findtail(dNode* L) { dNode* P = L; while (P->next != NULL) { P = P->next; } return P; } dNode* insertTail(dNode* tail, Elemtype e) { dNode* New = (dNode*)malloc(sizeof(dNode)); New->data = e; New->next = NULL; New->prev = tail; tail->next = New; return New; } //指定位置插入数据 int insertNode(dNode* L, int pos, Elemtype e) { dNode* P = L; int i = 0; while (i < pos - 1) { P = P->next; i++; if (P == NULL) { return 0; } } dNode* Q = (dNode*)malloc(sizeof(dNode)); Q->data = e; Q->prev = P; Q->next = P->next; P->next->prev = Q; P->next = Q; return 1; } //指定位置删除数据 int deleteNode(dNode* L, int pos) { dNode* P = L; int i = 0; while (i < pos - 1) { P = P->next; i++; if (P == NULL) { return 0; } } if (P->next = NULL) { printf("要删除的位置错位\n"); return 0; } dNode* Q = P->next; P->next = Q->next; Q->next->prev = P; free(Q); return 1; } //释放双向链表 dNode* freedNode(dNode* L) { dNode* P = L->next; dNode* Q; while (P != NULL) { Q = P->next; free(P); P = Q; } L->next = NULL; } int main() { dNode* dlist = initlist(); inserthead(dlist, 3); inserthead(dlist, 4); inserthead(dlist, 6); inserthead(dlist, 7); inserthead(dlist, 10); inserthead(dlist, 19); inserthead(dlist, 26); listdNode(dlist); dNode* tail = findtail(dlist); tail = insertTail(tail, 2007); listdNode(dlist); insertNode(dlist, 2, 0); listdNode(dlist); deleteNode(dlist, 2); listdNode(dlist); }数据结构-双向链表(核心代码)
张小明
前端开发工程师
PyCharm常用快捷键
1、按住CtrlQ或者CtrlShiftI快捷键可以查看函数定义 2、ShiftF6更改文件名 3、CtrlShiftF10运行程序
玩机搞机基本常识-------全交互式的Android现代反编译器 安卓应用编译工具 强烈推荐
在反编译一些安卓应用过程中。我们大都使用一些常用的反编译工具。例如手机端的mt管理器与电脑端各种成品类工具。但目前发现的这款反编译利器必须强烈推荐给大家使用。它不只是一款反编译器,同时也是一款轻便且功能强大的综合性逆向分析利器,其不依赖ja…
告别API碎片化与高成本 - 用AI Ping打造下一代智能编程工作流
AI Ping官方链接:https://aiping.cn/#?channel_partner_codeGQCOZLGJ 点击上述链接注册,将获得30元算力金, 小伙伴们快速体验AI Ping强大的功能吧~ 前言 在人工智能技术飞速发展的今天,AI编程助手已成为开发者提升效率的利器。…
实验记录。
Fi配了大半天,结果半天用木…。抓了一个后抓其他的可能导致网连不上,不知道是配置的问题,还是软件就是如此,运行过程中不能开其他的软件吗?以后试试吧。你开启Proxifier后其他软件出现异常,核心原因是Proxi…
SecureCRT SecureFX 9.7 for macOS, Linux, Windows - 跨平台的多协议终端仿真和文件传输
SecureCRT & SecureFX 9.7 for macOS, Linux, Windows - 跨平台的多协议终端仿真和文件传输 rock-solid terminal emulation & flexible secure file transfer for computing professionals 请访问原文链接:https://sysin.org/blog/securecrt-9/ 查看最新…
Magnet Axiom 9.9 Windows x64 Multilingual - 数字取证与分析
Magnet Axiom 9.9 Windows x64 Multilingual - 数字取证与分析 Digital Forensic Software 请访问原文链接:https://sysin.org/blog/magnet-axiom/ 查看最新版。原创作品,转载请保留出处。 作者主页:sysin.org Magnet Axiom 在一个案件中恢…