#include #include #include "pilha.h" int main(int argc, char* argv[]){ pilha P = NULL; char c; char topo; scanf("%c", &c); while(c != '\n'){ if(c == '+' || c == '-'){ P = desempilhar(P, &topo); while(topo != '('){ printf("%c", topo); P = desempilhar(P, &topo); } P = empilhar(P, '('); //retirei mas nao deveria P = empilhar(P, c); }else if(c == '('){ P = empilhar(P, c); }else if(c == ')'){ P = desempilhar(P, &topo); while(topo != '('){ printf("%c", topo); P = desempilhar(P, &topo); } }else if(c == '*' || c == '/'){ P = desempilhar(P, &topo); while(topo != '(' && topo != '+' && topo != '-'){ printf("%c", topo); P = desempilhar(P, &topo); } P = empilhar(P, topo); P = empilhar(P, c); }else{ printf("%c", c); } scanf("%c", &c); } return 0; }