栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > 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);
}

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/265951.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号