Nidhogg

Untitled

Jun 18th, 2012
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.06 KB | None | 0 0
  1. void insert(turboDrzewo* wierzcholek, char string[100])
  2. {
  3.     if(wierzcholek->strings == NULL) // pusta lista
  4.     {
  5.         wierzcholek->strings = new list;
  6.         wierzcholek->strings->next = NULL;
  7.         int i=0;
  8.         while(string[i] != NULL)
  9.         {
  10.             wierzcholek->strings->string[i]= string[i];
  11.             i++;
  12.         }
  13.         wierzcholek->strings->string[i] = NULL;
  14.     }
  15.     else if(!cmp(wierzcholek->strings->string, string)) // trzeba wstawic na sam poczatek
  16.     {
  17.         list* tmp = wierzcholek->strings;
  18.         wierzcholek->strings = new list;
  19.         wierzcholek->strings->next = tmp;
  20.        
  21.         int i =0;
  22.        
  23.         while(string[i] != NULL)
  24.             wierzcholek->strings->string[i] = string[i++];
  25.  
  26.         wierzcholek->strings->string[i] = NULL;
  27.     }
  28.     else // szukamy elementu po ktorym cza wstawic
  29.     {
  30.         list* lista = wierzcholek->strings;
  31.         while(lista->next!=NULL && cmp(lista->next->string, string))
  32.             lista = lista->next;
  33.         list* tmp = lista->next;
  34.         lista->next = new list;
  35.         lista->next->next = tmp;
  36.        
  37.         int i=0;
  38.         while(string[i] != NULL)
  39.             lista->next->string[i] = string[i++];
  40.         lista->next->string[i] = NULL;
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment