Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void insert(turboDrzewo* wierzcholek, char string[100])
- {
- if(wierzcholek->strings == NULL) // pusta lista
- {
- wierzcholek->strings = new list;
- wierzcholek->strings->next = NULL;
- int i=0;
- while(string[i] != NULL)
- {
- wierzcholek->strings->string[i]= string[i];
- i++;
- }
- wierzcholek->strings->string[i] = NULL;
- }
- else if(!cmp(wierzcholek->strings->string, string)) // trzeba wstawic na sam poczatek
- {
- list* tmp = wierzcholek->strings;
- wierzcholek->strings = new list;
- wierzcholek->strings->next = tmp;
- int i =0;
- while(string[i] != NULL)
- wierzcholek->strings->string[i] = string[i++];
- wierzcholek->strings->string[i] = NULL;
- }
- else // szukamy elementu po ktorym cza wstawic
- {
- list* lista = wierzcholek->strings;
- while(lista->next!=NULL && cmp(lista->next->string, string))
- lista = lista->next;
- list* tmp = lista->next;
- lista->next = new list;
- lista->next->next = tmp;
- int i=0;
- while(string[i] != NULL)
- lista->next->string[i] = string[i++];
- lista->next->string[i] = NULL;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment