数据结构:单链表就地逆置
以Head节点当作第三变量,不单独开辟新的节点空间。
void Inverse(SLNode *head) {
SLNode *p, *q;
p = head->next;
head->next = NULL;
while (p != NULL) {
q = p;
p = p->next;
q->next = head->next;
head->next = q;
}
}
分析:
网络上志同道合,我们一起学习网络安全,一起进步,QQ群:694839022