返回链表中间节点值

struct listnode* middlenode(struct listnode* head)
{
    struct listnode* fast=head;
    struct listnode* slow=head;
    if(head!=NULL)
    {
    while(fast!=NULL&&fast->next!=NULL)
    {
        fast=fast->next;
        slow=slow->next;
    }
    return slow;
    }
    return NULL;
}

猜你喜欢

转载自blog.csdn.net/weixin_43215068/article/details/88376683
今日推荐