單鏈表的基本操作(C語言實現)

2021-07-11 01:16:55 字數 802 閱讀 8772

//單鏈表的初始化,建立,插入,查詢,刪除。//  

#include #include typedef int elemtype;

//定義結點型別

typedef struct node

node,*linkedlist;

//單鏈表的初始化

linkedlist linkedlistinit()

//單鏈表的建立1,頭插法建立單鏈表

linkedlist linkedlistcreath()

return l;

}

//單鏈表的建立2,尾插法建立單鏈表

linkedlist linkedlistcreatt()

r->next = null;

return l;

}

//單鏈表的插入,在鍊錶的第i個位置插入x的元素

linkedlist linkedlistinsert(linkedlist l,int i,elemtype x)

//單鏈表的刪除,在鍊錶中刪除值為x的元素

linkedlist linkedlistdelete(linkedlist l,elemtype x)

pre->next = p->next; //刪除操作,將其前驅next指向其後繼。

free(p);

return l;

}

/ int main()

C語言實現單鏈表的基本操作

listnode.h ifndef listnode h define listnode h include stdio.h include assert.h include stdlib.h typedef int datatype typedef unsigned int size t type...

單鏈表 的基本操作 c語言實現

鍊錶的基本操作 c語言實現 執行環境 dev c 5.11 以下為原始碼,如有不正確的地方歡迎指正!include include define false 0 define true 1 typedef int datatype typedef struct nodelinklist linkli...

單鏈表的基本操作(C語言實現)

首先我來介紹一下要實現的的單鏈表基本基本操作有哪些 建立節點,頭尾的插入和刪除,某個位置的插入和刪除,查詢某個資料是否存在於單鏈表中。我們將從以下四方面對上述操作進行實現。1 單鏈表的結構體 typedef struct listnode listnode 2 以下是我們要實現的函式介面 listn...