Is this a school assignment?
Read as string
Split into tokens
Build parse tree
Optimize parse tree
Traverse optimized tree to emit answer
/Per W
On Fri, 5 Mar 2004, Sriram K wrote:
> hi guys,
> i am a newbie to dev as well as C++.
>
> now i have to read a mathematical expression from the console as a string and then do some calcultions with it.
> how do i go about performing calculation.
> the expression or eqn contains operators like +, -, / etc and also variables i.e alphabets like x,y etc.. in addition to numbers.
>
> is there some other to read the data rather than reading it into a string.
>
> or can something be done so that numerical calculations can be made.
>
> ex: read "2+3-x" should be able to output 5-x as the answer.
>
> please do help.
>
> - sriram
>
>
> Yahoo! India Insurance Special: Be informed on the best policies, services, tools and more.
|