首页 > 试题广场 >

试编写算法将不设表头结点得、不循环的单向链表就地逆转

[问答题]
试编写算法将不设表头结点得、不循环的单向链表就地逆转
void reverse(struct Node *a, struct Node *b)
{
    if (b -> next == NULL)
    {
        b -> next = a;
        return;
    }
    reverse(b, b -> next);
    b -> next = a;
}
//调用
reverse(NULL, head);


编辑于 2018-07-03 16:14:17 回复(0)
1
发表于 2018-07-02 01:55:26 回复(0)