- Jul 6, 2001
- 2,740
- 0
- 0
Here is the exact problem from my lab..
4)Create several stacks with a combo of parathesis.
Ex:
combo1--------------------------( ( ) ) )---------------------no
combo2--------------------------( ( ) )-----------------------YES
combo3--------------------------( ( ( ( ) ) )-----------------no
Create the function which will check the entire array to see if it has equal amount of parathesis!! (( )) = TRUE!! (( ) = FALSE (LIKE IN MATH PROBLEMS!!). YOU ARE NOT TO COUNT THE ( )¡¦S!!!
**************************************
SO how is that done? how can you check to see if they have equal amount of parathesis without using a counter for each type of parathesis?
I also thought about using a modulus-- % but that would only tell me if there are odd or even number of parens, not if they are pairs or not..
4)Create several stacks with a combo of parathesis.
Ex:
combo1--------------------------( ( ) ) )---------------------no
combo2--------------------------( ( ) )-----------------------YES
combo3--------------------------( ( ( ( ) ) )-----------------no
Create the function which will check the entire array to see if it has equal amount of parathesis!! (( )) = TRUE!! (( ) = FALSE (LIKE IN MATH PROBLEMS!!). YOU ARE NOT TO COUNT THE ( )¡¦S!!!
**************************************
SO how is that done? how can you check to see if they have equal amount of parathesis without using a counter for each type of parathesis?
I also thought about using a modulus-- % but that would only tell me if there are odd or even number of parens, not if they are pairs or not..