n**********E 发帖数: 157 | 1 for example,
given:
char a* = "1+2*3"
how to get:
int b = 1+2*3. | f******y 发帖数: 2971 | 2 use the binary tree.
【在 n**********E 的大作中提到】 : for example, : given: : char a* = "1+2*3" : how to get: : int b = 1+2*3.
| c*****t 发帖数: 1879 | 3 Look at this Lex/Yacc tutorial:
http://epaperpress.com/lexandyacc/
It apparently has a fairly good integer based math calculation
interpreter (including variable decl and loop etc).
Some slight modifications and you can have it to suit your need.
【在 n**********E 的大作中提到】 : for example, : given: : char a* = "1+2*3" : how to get: : int b = 1+2*3.
|
|