以下是結構什麼呢節點=節點 - >未來意味着鏈表(數據結構)
struct list *node
{
int data;
struct list *next;
}
什麼節點=節點 - >下一步究竟做遍歷該鏈表,而不是指向節點變量中指針的下一個元素指針?
以下是結構什麼呢節點=節點 - >未來意味着鏈表(數據結構)
struct list *node
{
int data;
struct list *next;
}
什麼節點=節點 - >下一步究竟做遍歷該鏈表,而不是指向節點變量中指針的下一個元素指針?
node = node-> next使節點指向鏈表中的下一個指針。 由於下一個存儲的值是指向列表中下一個元素的指針。 因此,將節點作爲node-> next,然後再次調用該函數或在for循環中迭代使您前進。 希望有幫助
想象一下用while
循環遞增一個變量。
int i = 0;
while (i < 6) {
// this loop will run forever without the line below
i++; // adds one to i so the loop will not run infinitely
}
的概念是與鏈表一樣:
while (node != NULL) {
//need to make sure this loop doesn't run forever
node = node->next // kind of like incrementing i
}
現在while循環運行,直到到達列表的末尾。