|
From: Hossein H. <ult...@em...> - 2004-03-08 08:19:41
|
Hi Sriram, > Is this a school assignment? > > Read as string > Split into tokens > Build parse tree > Optimize parse tree > Traverse optimized tree to emit answer Whether it is or not, my rule of thumb is that the following solution is one of the best, and the most mdern one: > > 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. Provided that you've got plausible methods to work with strings literals containg integers, using stringst -- ___________________________________________________________ Sign-up for Ads Free at Mail.com http://promo.mail.com/adsfreejump.htm |