📄 ttmain.c
字号:
#include <iostream.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <assert.h>
#include "book.h"
typedef int TELEM;
#include "ttnode.h"
#include "tttree.h"
int main()
{
TT tree;
TTNode* tnd;
cout << "IsEmpty: " << tree.isEmpty() << "\n";
tree.insert(10);
tree.print();
cout << "IsEmpty: " << tree.isEmpty() << "\n";
tree.remove(10);
tree.print();
cout << "IsEmpty: " << tree.isEmpty() << "\n";
tree.clear();
cout << "IsEmpty: " << tree.isEmpty() << "\n";
tree.insert(15);
tree.print();
cout << "IsEmpty: " << tree.isEmpty() << "\n";
tnd = tree.find(20);
if (tnd == NULL) cout << "Not found\n";
else cout << tnd->lkey << ", " << tnd->rkey << "\n";
tnd = tree.find(15);
if (tnd == NULL) cout << "Not found\n";
else cout << tnd->lkey << ", " << tnd->rkey << "\n";
tree.remove(20);
tree.insert(20);
tree.print();
tree.remove(20);
tree.print();
tree.insert(70);
cout << "IsEmpty: " << tree.isEmpty() << "\n";
tree.print();
tree.insert(35);
tree.print();
tree.insert(20);
tree.print();
tree.insert(17);
tree.print();
tree.insert(15);
tree.print();
tree.insert(19);
tree.print();
tree.insert(100);
tree.print();
tree.insert(90);
tree.print();
tree.insert(95);
tree.print();
tree.insert(1);
tree.print();
tnd = tree.find(100);
if (tnd == NULL) cout << "Not found\n";
else cout << tnd->lkey << ", " << tnd->rkey << "\n";
tnd = tree.find(99);
if (tnd == NULL) cout << "Not found\n";
else cout << tnd->lkey << ", " << tnd->rkey << "\n";
tnd = tree.find(20);
if (tnd == NULL) cout << "Not found\n";
else cout << tnd->lkey << ", " << tnd->rkey << "\n";
cout << "Need to do some delete tests.\n";
tree.remove(15);
tree.print();
tree.remove(15);
tree.print();
tree.remove(15);
tree.remove(70);
tree.print();
tree.clear();
tree.print();
cout << "IsEmpty: " << tree.isEmpty() << "\n";
return(0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -