第四周项目3 单链表应用1

来源:互联网 发布:天赋宝宝炼化软件 编辑:程序博客网 时间:2024/06/05 06:48

点击打开链接

#include"linklist.h"  int main()  {      linklist *L;      ElemType a[]= {1,3,5,7, 2,4,8,10};      CreateListR(L,a,8);      printf("L:");      DispList(L);      Reverse(L);      printf("逆置后L: ");      DispList(L);      DestroyList(L);      return 0;  }  
</pre><pre name="code" class="html">
</pre><pre name="code" class="html">  void Reverse(linklist *l)  {      linklist *p,*q;      p=l->next;      l->next=NULL;      while(p!=NULL)      {          q=p->next;          p->next=l->next;          l->next=p;          p=q;      }    }  



0 0
原创粉丝点击