Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include "RB.hpp"
- #include "Treap.hpp"
- using namespace std;
- int main() {
- RB *rb_tree = new RB();
- Treap *treap = new Treap();
- /*
- rb_tree->insert(0);
- treap->insert(0); ---- Добавление ключа
- rb_tree->remove(0);
- treap->remove(0); ---- Удаление ключа
- rb_tree->print();
- treap->print_sym();
- treap->print_direct(); Отображение деревьев на экране
- */
- int array[100*100];
- for (int i=0; i<100*100; i++)
- array[i]=0;
- int temp;
- FILE *f;
- int k=0;
- int ii=0;
- int count=0;
- if ((f = fopen("test", "rb")) == NULL)
- {
- printf("Ошибка открытия файла");
- }
- else
- {
- for (k=0;k<n;k++)
- {
- fscanf("%d", &temp);
- for (ii=0; ii<100*100; ii++) {
- if (array[ii] == temp)
- break;
- }
- if (ii != 100*100)
- continue;
- array[count]=temp;
- count++;
- }
- }
- fclose(f);
- return ;
- int array[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
- std::cout << "RB Tree->insert\n";
- std::cout << "Treap->insert\n";
- for (int i=0; i<10; i++) {
- std::cout << " " << array[i] << std::endl;
- rb_tree->insert(array[i]);
- treap->insert(array[i]);
- }
- std::cout << "\nRB Tree->print():\n";
- rb_tree->print();
- std::cout << "\nTreap->print_direct():\n";
- treap->print_direct();
- std::cout << "\nRB Tree->remove\n";
- std::cout << "Treap->remove\n";
- for (int i=0; i<10; i++) {
- std::cout << " " << array[i] << std::endl;
- rb_tree->remove(array[i]);
- treap->remove(array[i]);
- }
- std::cout << "\nRB Tree->print():\n";
- rb_tree->print();
- std::cout << "\nTreap->print_direct():\n";
- treap->print_direct();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement