Question
How would you instead of hard coding the postfix expression(char postfix[] = 12+56*9*-;) in instead take input from a user? #include #include using namespace std;
How would you instead of hard coding the postfix expression(char postfix[] = "12+56*9*-";) in instead take input from a user?
#include
using namespace std; //Expression tree node struct ETree { char value; ETree* left, *right; }; bool isOperator(char c) { if (c == '+' || c == '-' || c == '*' || c == '/' || c == '^') return true; return false; } //Inorder traversal of the tree void inorder(ETree *t) { if(t) { inorder(t->left); printf("%c ", t->value); inorder(t->right); } } ETree* newNode(int v) { ETree *temp = new ETree; temp->left = temp->right = NULL; temp->value = v; return temp; }; //Tree for the expression ETree* constructTree(char postfix[]) { stack
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started