previous | start | next

1.3.4 Details

1.3.4 Write a stack client Parentheses that reads in a text stream from standard input and uses a stack to determine whether its parentheses are properly balanced. For example, your program should print true for [()]{}{[()()]()} and false for [(]).

Adding word, etc., changes the solution to the problem only slightly.

That is, for input

      [(Hello) World!]{Is this balanced?}{[(one)(two)](three)}
   

the program should return true.

For input

      [(Is this ] balanced?)
   

the program should return false.



previous | start | next