void main() { Btree A; int array1[] = { 7, 4, 2, 3, 15, 35, 6, 45, 55, 20, 1, 14, 56, 57, 58 }; int array2[] = { 2, 1 }; int array[] = { 4, 2, 6, 1, 3, 5, 7 }; int k; k = sizeof(array1) / sizeof(array1[0]); cout << "建立排序二叉树顺序: " << endl; for (int i = 0; i<k; i++) { cout << array1[i] << " "; A.create_Btree(array1[i]); } cout << endl; cout << endl << "先序遍历序列: " << endl; A.display1(); cout << endl << "中序遍历序列: " << endl; A.display2(); cout << endl << "后序遍历序列: " << endl; A.display3(); cout << endl << "分层遍历序列: " << endl; A.display4(); cout << endl << "inorder is answer." << endl; system("PAUSE"); }
void main() { Btree A; int array1[] = { 7, 4, 2, 3, 15, 35, 6, 45, 55, 20, 1, 14, 56, 57, 58 }; int array[] = { 1, 2 }; int k; k = sizeof(array) / sizeof(array[0]); cout << "建立排序二叉树顺序: " << endl; for (int i = 0; i<k; i++) { cout << array[i] << " "; A.create_Btree(array[i]); } cout << endl; cout << "二叉树节点个数: " << A.count(A.root) << endl; cout << "二叉树叶子个数:" << A.findleaf(A.root) << endl; cout << "二叉树中度数为1的结点的数量为:" << A.findnode(A.root) << endl; cout << endl << "先序遍历序列: " << endl; A.display1(); cout << endl << "中序遍历序列: " << endl; A.display2(); cout << endl << "后序遍历序列: " << endl; A.display3(); cout << endl << "平衡树判断测试:" << endl; A.display4(); system("PAUSE"); }