int priority(char Operation){
if (Operation == '+' || Operation == '-'){
return 1; }
else if (Operation == '*' || Operation == '/'){
return 2; }
else { return 0; }
}
void Transform(char* Source, char* Result){
char stack[50] = { '0' };
int i = 0, j = 0, top = 0;
for (; Source[i] != '0'; i++){
if (Source[i] == '('){ stack[++top] = Source[i]; }
else if (Source[i] == ')'){
while (stack[top] != '(') {
Result[j++] = stack[top--]; }
top--;
}
else if (Source[i] == '*' || Source[i] == '/' ||
Source[i] == '+' || Source[i] == '-'){
while (priority(stack[top]) >=
priority(Source[i])){
Result[j++] = stack[top--]; }
stack[++top] = Source[i]; }
else
Result[j++] = Source[i]; }
while (top != 0){ Result[j++] = stack[top--]; }
}
int main(){
char Source[50] = { " a-d+(b*e)/c" },
Result[50] = { '0' };
Transform(Source, Result);
for (int i = 0; Result[i] != '0'; i++){
printf("%c", Result[i]); }
return 0;
}