各位大虾帮帮忙哈,急……呜哇
Write a procedure to reverse a singly linked list in O(N) time using constant extra space.一道数据结构的题,一点头绪也没耶,各位大虾帮帮忙哈,谢谢啦……很急耶
void revers(point head)//链表逆转置
{ point p,q,r;
p=head->next;
q=head->next;
r=q->next;
if(p==NULL || q==NULL)
printf("该链表无须转置。");
p->next=NULL; p=q;
while(r->next)
{
q=r; r=r->next;
q->next=p; p=q;
}
r->next=p; head->next=r;
}
[此贴子已经被作者于2006-9-22 13:02:29编辑过]
[此贴子已经被作者于2006-9-22 13:05:12编辑过]