鍊錶的建立

2021-08-19 21:35:50 字數 440 閱讀 1372

上學期c++老師教鍊表的時候沒有認真聽,這學期要補回來。今天就先來寫一寫鍊錶的建立的基本的**,輸入輸出的。

//正序輸入輸出

#include #include struct node

;struct node*creat(int n)//鍊錶的錄入

return head;

}void show(struct node*head)//鍊錶的輸出

}int main()

//逆序的

#include #include struct node

;struct node*creat(int n)

return head;

}void show(struct node*head)

}int main()

先這樣寫吧,以後可能會更改。

鍊錶(鍊錶建立)

先找到了一些與單鏈表相關的概念 2.指標域 ai元素儲存指向後繼元素儲存位置的資訊 3.結點 包含資料域和指標域 4.單鏈表 每個結點只包含乙個指標域的線性表 5.頭指標 要素 鍊錶中第乙個結點的儲存位置 線性表最後乙個結點指標為空 6.頭結點 非要素 單鏈表第乙個結點前附設乙個結點 其指標域指向第...

鍊錶的建立

動態鍊錶 1.建立鍊錶 動態鍊錶使用new delete需要新增標頭檔案stdlib.h同時我們需要注意的是這裡配合使用了指向前驅結點的指標pre和指向當前結點的p。通過資料域與指標域進行建立新結點。需要注意的是頭結點head的資料域是不儲存資料的。以下是基本的動態鍊錶的 include inclu...

鍊錶的建立

鍊錶的建立分為頭插法和尾插法 頭插法 1 含頭結點 include sstruct node typedef struct node linknode typedef linknode linklist linklist creatlink return head 2 不含頭結點 linklist ...