"> {data, count; _tree * left, * right;
}; _tree * root = NULL;// корінь дереваcount = 0;// счетчікmain ()
{number, s; (LC_ALL, "rus");
{(" tМЕНЮ n"); ("1.Добавіть елемент n"); ("2.Просмотр дерева n"); ("3.Очістіть дерево n "); (" 0.Виход n "); (" Вибрана дія: "); ("% d ", & s); (s)
{1: (" nВведіте елемент:"); ("% d", & number); (& root, number); (" nЕлемент доданий n n "); (" --------------------------- n n ");; 2: (root! = NULL )
{(" n"); (root, 0);
} (" nДерево пусте n n"); ("------------------------- - n n ");; 3: (& root); (" nДерево очищено n n "); (" ---------------- ----------- n n ");; 0: (1);: (" nОшібка! n n "); (" ------ --------------------- n n ");;
}
} while (s! = 0);
_getch ();
} Add (binar_tree ** current, int data)
{(* current! = NULL)
{(data <(* current) -> data) (& (* current) -> left, data); if (data> (* current) -> data) ( & (* current) -> right, data);
(* current) -> count + +;
}
{
* current = new binar_tree;
(* current) -> data = data;
(* current) -> left = NULL;
(* current) -> right = NULL;
(* current) -> count = 1; + +;
}
} Show (binar_tree * current, int l)
{(current! = NULL)
{(current-> right, l +1); (int i = 0; i data); (current-> left, l +1);
}
} Clear (binar_tree ** current)
{(* current! = NULL)
{(& (* current) -> left); (& (* current) -> right); * current; = count-1; (count == 0)
* current = NULL;
}
}