mihainan

Nan Mihai - Structuri de date (tema)

Apr 2nd, 2014
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.70 KB | None | 0 0
  1. typedef struct linie{
  2.     struct linie *prev;
  3.     char data;
  4.     struct linie *next;
  5. }linie;
  6.  
  7. typedef linie* Linie;
  8.  
  9. typedef struct text{
  10.     struct text *prev;
  11.     Linie data;
  12.     struct text *next;
  13. }text;
  14.  
  15. typedef text* Text;
  16.  
  17. Text addLast2(Text l, Linie val)
  18. {
  19.         Text nou, temp;
  20.         if (l==NULL)
  21.         {
  22.                 l = initText(val);
  23.         }
  24.         else
  25.         {
  26.                 nou=(text *)malloc(sizeof(text));
  27.                 temp=l;
  28.                 while(temp->next!=NULL)
  29.                         temp=temp->next;
  30.                 nou->data=val;
  31.                 nou->next=NULL;
  32.                 nou->prev=temp;
  33.                 temp->next=nou;
  34.         }
  35.         return l;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment