Tuesday, March 11, 2014

INFIX EXPRESSION solution using STACK in C++

#include<iostream>
#include<cstdlib>
using namespace std;
class stack
{
public:
int top=-1;
int s=10,a[20];
void push(int d);
int pop();
};
void stack::push(int d)
{
if(top>s-2)
cout<<"stack is full";
else
a[++top]=d;
}
int stack::pop()

{int c;
if(top<=-1){
cout<<"empty";
return 0;}
else
return (a[top]);
}
int main()
{
stack s;
int i=0;
char c[10];
cout<<"enter the infix expression";
cin.getline(c,10);

while(c[i]!='\0')
{

}}

No comments:

Post a Comment

Contributors

Translate