User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 456,602 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,499 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser: Programming Forums
Views: 499 | Replies: 1
Reply
Join Date: Mar 2007
Location: Honduras
Posts: 1,407
Reputation: Nichito is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 26
Featured Poster
Nichito's Avatar
Nichito Nichito is offline Offline
Nearly a Posting Virtuoso

leaves and nodes mathematical expression

  #1  
Sep 6th, 2007
ok guys... so here's a nice one...

suppose i have a matematical expression with variables less than 10 and greater than 0... and i divide the mathematical expression in leaves and nodes, being the operands the leaves and the operators the nodes...
something like this:
 (w+x)*(y-z)

          *
         / \
        +   -
       / \  | \  
      w   x y  z

hope you understand it...

the problem is: the mathematical expression must be input by the user, and the program must break it down... and at the end it must show the result...
-->sometimes i wanna take my toaster in a bath<--
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2007
Posts: 321
Reputation: Hamrick will become famous soon enough Hamrick will become famous soon enough 
Rep Power: 3
Solved Threads: 33
Hamrick's Avatar
Hamrick Hamrick is offline Offline
Posting Whiz

Re: leaves and nodes mathematical expression

  #2  
Sep 6th, 2007
the problem is: the mathematical expression must be input by the user, and the program must break it down...
Any user input has to be validated first. Once you read the string you need to go over it and make sure that all of the parentheses are matched the right way and all of the operators have the right number of operands.

When the string is validated, you can convert it to reverse polish notation and build the expression tree from that.
The truth does not change according to our ability to stomach it.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb C++ Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the C++ Forum

All times are GMT -4. The time now is 7:07 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC