Infix to postfix algorithm that takes care of unary operators

后端 未结 3 1858
南笙
南笙 2021-01-05 13:49

The I/p to the algo will be an expression like this:

a+(-b)
a*-b+c

i.e any expression that a standard C compiler would support.

Now

3条回答
  •  温柔的废话
    2021-01-05 14:30

    If an operator is the first thing in your expression, or comes after another operator, or comes after a left parenthesis, then it's an unary operator.

    You have to use another symbols for unary operators in your output string, because otherwise it is not possible to distinguish between binary and unary variants in the postfix notation.

提交回复
热议问题