/*
* 鍊錶相對於陣列:
* 插入和刪除的效率高;
* 查詢效率低;
* 儲存額外的節點指標,帶來空間上的消耗;
*/#include using namespace std;
//定義鍊錶的資料結構
struct listnode
};//建立單向鍊錶
listnode* list_create()
return phead->next;
}// 列印單向鍊錶
void list_print(listnode* phead)
coutpcurrent = pcurrent->next;
}if(pcurrent == null)
return phead;
}//刪除
listnode* list_delete(listnode* phead, int data)
while(pcurrent)
if(pcurrent == null)
return phead;
}//銷毀單向鍊錶
int list_destory(listnode* phead)
return 0;
}int main()
C 鍊錶基本操作
includeusing namespace std struct node typedef node mylist void createlist mylist head,int n 1 mylist copylist mylist l 2 void insertelem mylist head,...
鍊錶的基本操作 C
define crt secure no warnings include include include include include include linklist.h 初始化鍊錶 struct linknode init linklist pheader頭指標用來返回首位置 ptail中間...
雙向鍊錶的基本操作 C
參考其他人的雙向鍊錶實現,搞了乙個便於自己理解的練練筆。include include using namespace std 定義乙個節點 typedef struct doublelinknode node 建立乙個鍊錶 node create list int nums,int n retur...