Infix to Postfix with function support

后端 未结 5 872
无人及你
无人及你 2021-01-15 21:34

There are many algorithms to convert infix to postfix all over the web. But my question is how to make that to support functions? For example sin(x+y)*z.

I will appr

5条回答
  •  借酒劲吻你
    2021-01-15 22:31

    Thats quite easy: It work with functions too, the regular operators you use (like +,-,*) are functions too. Your problem is, that what you consider "function" (like sin) is not in infix, but they are in prefix.

    To come back to your problem: Just convert these prefix functions into postfix (you should find prefix to postfix on the web too - my assumption is that you dont know the "prefix" term) beforehand.

    EDIT: Basicaly it is nothing more that first convert the arguments and output them in sequence and append the name of the function afterwards.

提交回复
热议问题