C 筆試題(單向鍊錶)

2021-08-10 16:06:33 字數 1215 閱讀 4671

#ifndef f_test_2017_11_11_11_jhaskdfjhasf_h_

#define f_test_2017_11_11_11_jhaskdfjhasf_h_

#include

/*單向鍊錶操作

*/template

struct fsingletonnode

;//清空節點所有資料

template

void clearlist(fsingletonnode

**phead)

phead =

null;

}//列印資料

template

void printlite(fsingletonnode

*phead)

else

if (0

== strcmp(ttype, "float"))

pcurnode = pcurnode->pfnodenext;

}trace("\n");

}//在節點末尾,新增資料

template

bool pushback(fsingletonnode

**phead, const t tvalue)

else

//將新建立節點設為尾節點

pendnode->pfnodenext = pcurnode;

}return

true;

}//根據資料,刪除節點

template

bool removenode(fsingletonnode

**phead, const t tvalue)

fsingletonnode

*pdeletenode =

null;

//如果需要刪除的是第乙個節點

if((*phead)->tvalue == tvalue)

else

if(pprenode->pfnodenext && (pprenode->pfnodenext->tvalue == tvalue))

}//釋放需要刪除的節點資料

if (pdeletenode)

return

true;

}//測試

void f_test_list()

#endif

//f_test_2017_11_11_11_jhaskdfjhasf_h_

C 單向鍊錶

單向鍊錶 鍊錶的功能包括 向尾節點新增資料,遍歷鍊錶中的節點,在鍊錶結束時釋放所有節點 class cnode 定義乙個節點類 class csllist 定義鍊錶類csllist類 csllist m nodesum 0 pdelete null ptmp null m pheader null ...

C 單向鍊錶

實現鍊錶的增刪改查 ownlinklist.cpp include include include ownlinklist.h include using namespace std node init node get elment node list,int index if i index 1...

鍊錶常見筆試題

鍊錶的一些常見筆試面試問題總結及 先什麼也不說,假設鍊錶節點的資料結構為 struct node 建立單鏈表的程式為 struct node create unsigned int n node p head for unsigned int i 1 i n i return head 問題1 鍊錶...