/p>
* H=T; (Temp);
* status=1;
} if (Temp- gt; Left_Child == NULL)
{= Temp- gt; Right_Child;
* H=T; (Temp);
* status=1;
}
{ gt; Left_Child=Delete (Temp- gt; Left_Child, Temp, H); (* H)=Balance_Right_Heavy (Parent, H);
* status=1;
}
}
} (Parent);
}
//----------------------------------------
/* видалення всього дерева */DeleteAllAVL (struct NODE ** Parent)
{NODE * t=* Parent; (t!=NULL)
{( amp; t- gt; Left_Child); ( amp; t- gt; Right_Child); (t);
}
}
//----------------------------------------
/* Висновок дерева */Output (struct NODE * Tree)
{(Tree)
{(Tree- gt; Left_Child); ( n№ готельного номера:% s nКолічество місць:% i nКолічество кімнат:% i nНалічіе санвузли:% c nОборудованіе:% s n n raquo ;, Tree- gt; Number, Tree- gt; CountBads, Tree- gt; CountRooms, Tree- gt; toilet, Tree- gt; equipment); (Tree- gt; Right_Child);
}
}
//----------------------------------------
/* функція пошуку підрядка за алгоритмом Боуер-Мура */boyer_moore (char * haystack, char * needle)
{i, j, k; needle_table [256]; needle_len=strlen (needle); haystack_len=strlen (haystack); * tmp=(char *) malloc (haystack_len * sizeof (char)) ; (tmp, haystack); (needle_len lt;=haystack_len)
{(i=0; i lt; 256; i ++) _ table [i]=needle_len; (i=1; i lt; needle_len; i ++) _ table [needle [i]]=needle_len-i;=needle_len;=i; ((j gt; 0) amp; amp; (i lt;=haystack_len))
{= needle_len;=i; ((j gt; 0) amp; amp; (tmp [k - 1] == needle [j - 1]))
{-; -;
} +=needle_table [tmp [i]];
} (k gt; haystack_len - needle_len) 0; k + 1;
} 0;
}
//----------------------------------------
/* пошук № за номером готельного номера */find_hotel_room (struct NODE * Tree, char * Number, struct element * pbegin, struct NodeHash ** hashtable, int * status)
{element * pv=pbegin; hashkey; NodeHash * tmp; (Tree)
{_ hotel_room (Tree- gt; Left_Child, Number, pbegin, hashtable, status); _ hotel_room (Tree- gt; Right_Child, Number, pbegin, hashtable, status); (strcmp (Tree- gt; Number, Number) == 0)
{
* status=1; ( n№ готельного номера:% s nКолічество місць:% i nКолічество кімнат:% i nНалічіе санвузли:% c nОборудованіе:% s n n raquo ;, Tree- gt; Number, Tree- gt; CountBads, Tree- gt; CountRooms, Tree- gt; toilet, Tree- gt; equipment); (pv!=0)
{(strcmp (pv- gt; Number, Number) == 0)
{( nНомер паспорта заселеного постояльця:% s raquo ;, pv- gt; passport);=hash (pv- gt; passport);=* (hashtable + hashkey); (tmp! =0)
{(strcmp (tmp- gt; passport, pv- gt; passport) == 0) ( nФІО:% s , tmp- gt; fio);=tmp- gt; next;
}
}=pv- gt; next;
}
}
}
}
//----------------------------------------
/* шукаємо номера за фрагментами обладнання */findequip (struct NODE * Tree, char * equip, int * status)
{(Tree)
{(boyer_moore (Tree- gt; equipment, equip))
{( n№ готельного номера:% s nКолічество місць:% i nКолічество кімнат:% i nНалічіе санвузли:% c nОборудованіе:% s n n raquo ;, Tree- gt; Number, Tree- gt; CountBads, Tree- gt; CountRooms, Tree- gt; toilet, Tree- gt; equipment);
* status=1;
} (Tree- gt; Left_Child, equip, status); (Tree- gt; Right_Child, equip, status);
}
}
//----------------------------------------
/* перевірка наявності готельного номера в базі (пошук номера в дереві)
і обчислюємо кількість залишилися вільних місць в номері */find_numbers (struct NODE * Tree, char * Number, int * status, int * CountFreeBads, int key)
{(Tree)