这是一个返回链表的第 n 个节点的函数,但是编译器错误总是说返回类型应该是 int。这是为什么?
struct Node *getNthNode(struct Node* head, int index)
{
if (head==NULL)
return NULL;
struct Node *current = head;
int count = 0;
while (current)
{
if (count == index)
return(current);
count++;
current = current->next;
}