void PostOrderPrintTree(PNode node) { if (node) { PostOrderPrintTree(node->left); PostOrderPrintTree(node->right); printf("%s ", node->data); } }
int main() { // valid operators: + - * / ( ) // valid operands: integers // whitespace separated as: ( 1 + 2 ) * 3 char exp[20]; scanf("%[^\n]", exp); PNode root = CreateInfixTree(exp); PostOrderPrintTree(root); printf("\n"); return 0; }
void TestForSearhTree::Run() { ConsoleMenu* cMenu = new ConsoleMenu(); SearhTree<int, Elephant> searhTree(KeyGenElephantAge, compareForInt);//before while! Node<int, Elephant> *x; Elephant *el; int variant; system("cls"); while (true){ variant = cMenu->getMenuForSearhTree(); cout << endl; system("cls"); Elephant elephant; double weight; char* color = new char[40]; char* name = new char[40]; int age; vector<Elephant> v; switch (variant) { case 1:{ AddElementToTree(&searhTree); break; } case 2:{ PreOrderPrintTree(&searhTree); break; } case 3:{ InOrderPrintTree(&searhTree); break; } case 4:{ PostOrderPrintTree(&searhTree); break; } case 5:{ SearchValueByKeyInTree(&searhTree); break; } case 6:{ cout << "Get as sorted array" << endl << endl; v=searhTree.GetAsSortedArray(); if (v.size() == 0) cout << "Tree is empty" << endl << endl; else cout << "Tree as sorted array" << endl << endl; for (int i = 0; i < v.size(); i++) { cout << v[i] << endl; } system("pause"); break; } case 7: { return; } } } //system("pause"); }