帶頭節點且迴圈的雙鏈表

2021-08-28 07:19:23 字數 1056 閱讀 6937

由於很簡單,直接上**

#pragma once

#include "stdio.h"

#include "assert.h"

#include "stdlib.h"

typedef int datatype;

typedef struct dnode

dn;//建立節點

dn* creatednode(datatype d)

//初始化/銷毀

void initdlist(dn** phead)

//清空鍊錶(保留頭結點)

void empty(dn* head)

head->next = head->prev = null;

}void destroydlist(dn* head)

// 插入到 pos 的前面 (pos一定在鍊錶中)

void insertdlist(dn* head, dn* pos, datatype d)

// 鍊錶插入在前面

// 和單鏈表的區別,不需要二級指標了

void pushfront(dn* head, datatype d)

void pushback(dn* head, datatype d)

// pos 是鍊錶中的任意乙個結點(頭結點)

void erase(dn* head, dn*pos)

void popfront(dn* head)

void popback(dn* head)

void printdlist(dn* head)

printf("null\n");

}dn* find(dn* head, datatype d)

cur = cur->next;

} return null;

}

#define _crt_secure_no_deprecate 1

#include "dlist.h"

void test()

int main()

C語言實現非迴圈雙鏈表節點的刪除(帶頭結點尾結點)

我在之前一篇部落格 c語言實現非迴圈雙鏈表節點的刪除 不帶頭結點 中詳細講解了不含頭尾節點的雙鏈表中刪除乙個節點,處理過程還是稍顯麻煩。自從我們學習使用頭尾節點來處理雙鏈表後,刪除過程就非常方便。上傳至 核心 如下 刪除pos位置的節點 int deleteposlist node phead,no...

帶頭節點的單鏈表

需要注意 include define maxlen 20 define elementtype char using namespace std typedef struct slnode node 函式宣告 void initiallist node l int listlength node ...

判斷帶頭結點的迴圈雙鏈表是否對稱

include stdafx.h include include includetypedef int type typedef struct lnode 定義鍊錶結點的資料結構 lnode typedef lnode node typedef struct dnode 定義雙鏈表結點的資料結構 d...