Palindrome problem

hey guys can someone help me in my project:

i can only use array no other than..

just iostream lib.

the problem is arranging the parenthesis.
a open parenthesis should be paired to a nearest close parenthesis.
but if it has a unpaired parenthesis. parenthesis would be convert to a bracket. open parenthesis=open bracket close prnthsis. would be close brcket.

input is: ( ) ( ) ( ( )
output : ( ) ( ) [ ( )
Last edited on
My suggestion:
1.) Copy the string
2.) replace each occurence of ("n times x") with x"n times x"x
3.) repeat step 2 until you can't replace anymore
4.) remaining ( or ) mark positions that have to be transformed to [ or ]

or do it rescursively.

Example:
()(())(()
xx(())(()
xx(xx)(()
xxxxxx(()
xxxxxx(xx
xxxxxx(xx
Topic archived. No new replies allowed.