⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 infix.cpp

📁 datastucutre and algorithms, application, in C
💻 CPP
字号:
// generate infix from expression tree

#include <iostream>
#include "binaryTreeNode.h"

using namespace std;

template <class T>
void infix(binaryTreeNode<T> *t)
{// Output infix form of expression.
   if (t != NULL)
   {
      cout << '(';
      infix(t->leftChild);   // left operand
      cout << t->element;    // operator
      infix(t->rightChild);  // right operand
      cout << ')';
   }
}

int main(void)
{
   binaryTreeNode<int> x,y,z;
   x.element = 1; y.element = 2; z.element = 3;
   x.leftChild = &y; x.rightChild = &z;
   y.leftChild = y.rightChild = z.leftChild = z.rightChild = 0;
   infix(&x);
   cout << endl;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -