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

2023-07-06   


解: 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);
  


相关内容:

  1. 链表面试题-一个链表的结点结构
  2. 写出程序把一个链表中的接点顺序倒排
  3. C++面试题:关于链表和指针
  4. 一套VC试题
  5. 普天C++笔试题
  6. 华为慧通笔试题