鍊錶的操作

2021-07-28 00:13:28 字數 684 閱讀 7201

鍊錶是面試中常考的型別,因為只有幾行就可以了。

下面是一些鍊錶**

// keshan.cpp : 定義控制台應用程式的入口點。

//#include "stdafx.h"

#include #include #define null 0

#define len sizeof(struct node)

struct node;

//列印鍊錶

void print_link(node *head)

}int _tmain(int argc, _tchar* argv)

while(p->next != null);

//查詢第2個,第乙個即為0

printf("遍歷第2查詢\n");

p = head;

for(int i=1;i<3;i++)

printf("%d\n",p->value);

//修改第3個,數值改為30

printf("修改第3個\n");

p = head;

for(int i=0;i<3;i++)

p->value = 30;

print_link(head);

//刪除

getchar();

return 0;

}

鍊錶的操作

鍊錶是資料結構中的乙個重要組成部分,對鍊錶操作的熟練度怎麼要求都不過分。只有部分核心 主要內容 1 鍊錶的建立 2 鍊錶的釋放 3 鍊錶的查詢 4 鍊錶中節點的插入 5 鍊錶中節點的刪除 6 鍊錶的反轉 7 兩個鍊錶的連線 define max 15 節點宣告 struct list typedef...

鍊錶的操作

結點0為頭結點,不儲存有意義的資料 從結點1開始儲存有意義的資料 include include includetypedef struct node node,pnode pnode create list 建立乙個新鍊錶 void show list pnode 遍歷顯示鍊錶 void add ...

鍊錶的操作

鍊錶有單向鍊錶雙向鍊錶,迴圈鍊錶和不迴圈,還有帶表頭和不帶表頭。鍊錶的操作步驟基本一致 以不帶表頭的單向不迴圈鍊錶為例 1.先定義乙個結構體,作為鍊錶的節點來使用,例如 struct node typedef struct node node typedef struct node link 2.然...