2015-04-03 32 views

回答

0

node = node-> next使節點指向鏈表中的下一個指針。 由於下一個存儲的值是指向列表中下一個元素的指針。 因此,將節點作爲node-> next,然後再次調用該函數或在for循環中迭代使您前進。 希望有幫助

0

想象一下用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循環運行,直到到達列表的末尾。

相關問題