//利用快慢指针快速得到链表中间节点 int getMiddleNodeValue(LIST * l) { NODE * search, * middle; search = l->head; middle = l->head; while (NULL != search->next) { if (NULL != search->next->next) { search = search->next -> next; middle = middle->next; } else{ search = search->next; } } return middle->i; }
时间: 2024-11-05 18:46:58