“`”

【参考答案】从第一个元素开始,ps指向他,将他(ps)指向头节点(ps->next = head) ,将ps设为头节点(head = ps; )操作下一个元素(ps= pe->next;)等于是依次将每个元素翻到原头节点前面。

<pre><code>void reverse(test* head)
{
test* pe = head;
test* ps = head->next;
while(ps)
{
pe->next = ps->next;
ps->next = head;
head = ps;
ps = pe->next;
}
}
</code></pre>

<pre><code> "“`

Was this helpful?

0 / 0

发表回复 0

Your email address will not be published.