Container adaptors

This is a discussion on Container adaptors within the C++ Programming forums, part of the General Programming Boards category; I have this problem form a book C++ primer *Use a stack to process parenthesized expressions. When you see an ...

  1. #1
    Registered User
    Join Date
    Jan 2013
    Posts
    114

    Container adaptors

    I have this problem form a book C++ primer
    *Use a stack to process parenthesized expressions. When
    you see an open parenthesis, note that it was seen. When you see a close
    parenthesis after an open parenthesis, pop elements down to and including
    the open parenthesis off the stack. push a value onto the stack to
    indicate that a parenthesized expression was replaced.
    , Now I dont have a idea what to do? should I remove the parenthesiszed elements? than How would I do that? if the parentheses come after some time, than I cant pop it because stacks pops the first element. or should I pop all the elements upto the first parentheses is found? and should I use a string as an underlying container>??

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,855
    I would suggest you work through 2 * ( 3 + 4 ), by writing each symbol on a piece of paper, and stacking said pieces of paper in a stack (as described).

    So when you see the ")" piece of paper, you can then look at your stack of paper (with the "4" on top of it), and then follow the instructions.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Jan 2013
    Posts
    114
    Owh.. I get it.. thanks..

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Looking for appropriate container
    By Elysia in forum C++ Programming
    Replies: 20
    Last Post: 07-27-2010, 05:51 PM
  2. container
    By lopezA in forum C++ Programming
    Replies: 5
    Last Post: 12-04-2007, 11:10 AM
  3. Replies: 1
    Last Post: 01-23-2006, 07:12 PM
  4. Replies: 4
    Last Post: 03-21-2004, 03:34 PM
  5. I/O using a STL container
    By LA Mills in forum C++ Programming
    Replies: 5
    Last Post: 04-20-2003, 01:15 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21