Posted in 面试题 onFebruary 10, 2016
解: 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);
}
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);
}
编写一子程序,将一链表倒序,即使链表表尾变表头,表头变表尾
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Tags in this post...
Reply on: @reply_date@
@reply_contents@