面试啦 - 提供专业面试问题及答案、面试技巧、助您成功面试!
您的当前位置:首页 > 面试题库 > IT面试题 > C++面试题 > 正文

编写一子程序,将一链表倒序,即使链表表尾变表头,表头变表尾

解: 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);
}
词条:c面试题
上一篇:凌阳科技股份有限公司C++程序员面试题笔试题 下一篇:C++面试题:关于链表和指针
与该文相关的文章

温馨提示:如果您对面试网有任何建议,请通过网站联系邮箱向我们反馈,感谢各位的建议与支持!