1
我對下面的一段代碼有幾個問題。請多多包涵。代碼可能很容易理解,但我仍處於學習過程中,所以對我來說這仍然是抽象的。將線性鏈表轉換爲循環鏈表
struct listNode {
int data;
struct listNode *next };
//Is J a pointer, pointing to the head of the linked list?
struct listNode * convert (struct listNode * J) {
if (J == NULL)
return NULL;
//Is this creating a new temporary pointer that will traverse the linked list?
//Is it being set to J so that it can start at the first node and go to the last?
struct listNode * temp = J;
while (temp -> next != NULL)
temp = temp->next; //Is this where the temp pointer actually goes through the list?
//Temp->next will eventually become the last node of the list and that will be set to J
//which is the head pointer?
temp->next = J;
return temp;
}
和你的問題是什麼? – sdadffdfd 2011-01-20 03:54:30
我的問題在 – kachilous 2011-01-20 03:57:21