void TestFarthest() { cout << "TestFarther()--------------------------------------------------" << endl; t1.Print(); cout << t1.GetFarthest() << endl; t2.Print(); cout << t2.GetFarthest() << endl; }
void TestIsComplete() { cout << "TestIscomplete()--------------------------------------------------" << endl; t0.Print(); cout<<t0.IsComplete()<<endl; t1.Print(); cout << t1.IsComplete() << endl; t2.Print(); cout<<t2.IsComplete()<<endl; }
int main() { int select = -1; Tree tree; while (true) { cout << "0: Exit" << endl; cout << "1: Add" << endl; cout << "2: Search" << endl; cout << "3: Load Preset Tree" << endl; cout << "4: Print" << endl; cin >> select; if (select == 0) return 0; if (select == 1) tree.EnterID(); if (select == 2) tree.Search(); if (select == 3) tree.Preset(); if (select == 4) tree.Print(); } }
int _tmain(int argc, _TCHAR* argv[]) { Tree<int>* tr = new Tree<int>(); tr->Add(123, "abcdef"); tr->Add(456, "abde"); tr->Add(789, "aaaa"); tr->Add(145, "a"); tr->Add(464, "ab"); tr->Print("Tree"); cout << endl; tr->Add(444, "a"); cout << endl; tr->Find("abde"); cout << endl; tr->Delete("abde"); tr->Print("After deleting record (key - abde)"); getchar(); return 0; }
void TestTree() { cout << "TestTree()--------------------------------------------------" << endl; int prev0[] = { 1, 2, 4, 3, 5 }; int in0[] = { 4, 2, 1, 5, 3 }; Tree<int> t0(prev0, sizeof(prev0)/sizeof(prev0[0]), in0, sizeof(in0)/sizeof(in0[0])); t0.Print(); int prev1[] = { 1, 2, 3, 4, 5, 6 }; int in1[] = { 3, 2, 4, 1, 6, 5 }; Tree<int> t1(prev1, sizeof(prev1)/sizeof(prev1[0]), in1, sizeof(in1)/sizeof(in1[0])); t1.Print(); int prev2[] = { 1, 2, 4, 5, 3, 6, 7 }; int in2[] = { 4, 2, 5, 1, 6, 3, 7 }; Tree<int> t2(prev2, sizeof(prev2)/sizeof(prev2[0]), in2, sizeof(in2)/sizeof(in2[0])); t2.Print(); }
void TestGrandfather() { cout << "TestGrandfather()--------------------------------------------------" << endl; t1.Print(); //int x = 6; //cout << t1.Find(x) << endl; int x = 3; int y = 6; t1.GetNearestGandfather(t1.Find(x),t1.Find(y)); }
void menu() { Tree *tree = new Tree; char c; do { printf("1: View\n"); printf("2: Find\n"); printf("3: Add\n"); printf("4: Del\n"); printf("5: Clear\n"); printf("\nEsc: Exit\n"); c = getch(); switch(c) { case '1': cout << "Print:"; tree->Print(); cout << endl; break; case '2': cout << "Find:"; int val; cin >> val; bool flag; flag = tree->Exists(val); cout << (flag == true ? "true" : "false") << endl; break; case '3': cout << "Add:"; int add; cin >> add; tree->Add(add); cout << endl; break; case '4': cout << "Delete:"; int del; cin >> del; tree->Delete(del); cout << endl; break; case '5': tree->Clear(); cout << endl; break; } } while(c != 27); delete tree; }
void TestTransform() { t1.Print(); t1.Transform(); }