嘻皮客娱乐学习网
标题:
编写一子程序,将一链表倒序,即使链表表尾变表头,表头变表尾
[打印本页]
作者:
服装批发
时间:
2014-11-30 10:07
标题:
编写一子程序,将一链表倒序,即使链表表尾变表头,表头变表尾
解: struct example *reverse(head)
struct example *head;
{
struct example p1,p2;
p1=(struct example *)malloc(size);
p1->key=head->key;
p1->next=NULL;
while(head->next!=NULL)
{
p2=head->next;
head->next=(head->next)->next;
p2->next=p1->next;
p1->next=p2;
}
head=p1;
return(head);
}
欢迎光临 嘻皮客娱乐学习网 (http://www.xipick.com/)
Powered by Discuz! X3.3