#include <iostream>
#include <conio>
void pop(char,int*,char*);
void print(char*);
char push(int*,char*);
char in[50],out[50],stack[50],ch;
int main()
{
int top=-1,i,j=0;
clrscr();
cout<<"\n\nPlease enter your prasse:";
cin>>in;
for(i=0;i<50;i++)
{
if((in[i]>96&&in[i]<123)||(in[i]>64&&in[i]<91))
{
out[j]=in[i];
++j;
}
else if(in[i]!=')')
pop(in[i],&top,stack);
else if(in[i]==')')
{
while(top>-1)
{
ch=push(&top,stack);
if(ch!='(')
{
out[j]=ch;
++j;
}
}
}
}
print(out);
print(stack);
getch();
return 0;
}
//*************************************
void pop(char x,int* up,char *stack)
{
*up+=1;
if(*up>49)
cout<<"Sorry Stack Is Full";
else
stack[*up]=x;
}
//*************************************
char push(int *up,char *stack)
{
if(*up<0)
cout<<"\nSorry Stack Is Empety\n\n";
else
*up-=1;
return stack[*up+1];
}
//*************************************
void print(char*s)
{
for(int i=0;i<50;i++)
if(s[i])
cout<<s[i];
}