Stack using C++ programmijng language please Write a program to input an arithmetic expression, then 1. Match nested brackets found the expression, if they are matched correctly proceed to step 2. 2. Evaluate the expression. Please not that the operands of the expression may contain more than one digit. just 3 function : 1.function to check the brackets 2.function from infix to postfix 3.function to evaluate the expression this is the cin of the arithmetic expression is : ((5+(6/2*3)-2)+1)= you can use this function also :::
Stack using C++ programmijng language please
Write a program to input an arithmetic expression, then
1. Match nested brackets found the expression, if they are matched correctly proceed to step 2.
2. Evaluate the expression.
Please not that the operands of the expression may contain more than one digit.
just 3 function :
1.function to check the brackets
2.function from infix to postfix
3.function to evaluate the expression
this is the cin of the arithmetic expression is :
((5+(6/2*3)-2)+1)=
you can use this function also :::
struct node
{ int data; node *next;
node(int d,node *n=0)
{ data=d; next=n; }
};
class stack
{
node *topp;
public: stack();
void push(int el);
bool pop();
int top();
bool top(int &el);
//~stack();
//void operator=(stack &o);
//stack(stack &o); };
stack::stack()
{ topp=0; }
void stack::push(int el)
{ topp=new node(el,topp); }
bool stack::pop()
{ if(topp==0)
return false;
node *t=topp;
topp=topp->next;
delete t;
return true; }
int stack::top()
{ if(topp!=0)
return topp->data; }
bool stack::top(int &el)
{ if(topp==0)
return false;
el=topp->data;
return true; }
Step by step
Solved in 3 steps with 6 images