char stack[401];
int index=-1;
void push(char value);
main()
{
char arr[401];//remember this you always forget : 1 extra for ‘\0’
char out[401];
int i,t=0,k=0;
scanf("%d",&t);
while(t--)
{
k=0;
i=0;
scanf("%s",arr);
while(arr[i]!='\0')
{
if(arr[i]=='('){push(arr[i]);}
if(arr[i]=='*'){push(arr[i]);}
if(arr[i]=='-'){push(arr[i]);}
if(arr[i]=='+'){push(arr[i]);}
if(arr[i]=='/'){push(arr[i]);}
if(arr[i]=='^'){push(arr[i]);}
if(arr[i]>='a'&& arr[i]<='z' )
{
out[k]=arr[i];
k++;
}
if(arr[i] == ')')
{
while(stack[index]!='(')
{
out[k]= pop();
k++;
}
pop();
}
i++;
}
for(i=0;i<k;i++)
{
printf("%c",out[i]);
}
}
}
void push(char value)
{
index++;
stack[index] = value;
}
pop()
{
index–;
return(stack[index+1]);
}
guys i followed strict rule of parenthesis as no priorotization of operators needed here … guys can you plz help me out here if i am missing any case here it would be really helpfull…
When i submit i get Wrong answer but i got correct for test cases and some of my expressions also worked fine …