Copy generalized table

From , 3 Years ago, written in C, viewed 227 times.
URL https://pastebin.vip/view/05546b0e
  1. int CopyGList ( GList ls1, GList *ls2 )
  2. {
  3.         if ( !ls1 ) *ls2 = NULL; /*复制空表*/
  4.         else
  5.         {
  6.                 if ( ! ( *ls2 = ( Glist ) malloc ( sizeof ( Glnode ) ) ) ) return 0; /*建表结点*/
  7.                 ( *ls2 )->tag = ls1->tag;
  8.                 if ( ls1->tag = = 0 ) ( *ls2 )->data = ls1->data; /*复制单元素*/
  9.                 else
  10.                 {
  11.                         CopyGList ( & ( ( *ls2 )->ptr.hp ), ls1->ptr.hp ); /*复制广义表ls1->ptr.hp 的一个副本*/
  12.                         CopyGList ( & ( ( *ls2 )->ptr.tp ) , ls1->ptr.tp ); /*复制广义表ls1->ptr.tp 的一个副本*/
  13.                 }
  14.         }
  15.         return 1;
  16. }
  17.  

Reply to "Copy generalized table"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website