Given the following input to the program:
- List of block start characters
- List of block end characters
- A string to format
format the string with the blocks delimited by the two character sets indented.
Formatting is done with two spaces per level and the parentheses are placed as shown in the example below. You may assume the sets of opening and closing characters to be disjoint.
E.g. for {[(<
and }])>
as the opening and closing character sets and the following string:
abc{xyz{text[note{comment(t{ex}t)abc}]}}
the following output would be expected:
abc
{
xyz
{
text
[
note
{
comment
(
t
{
ex
}
t
)
abc
}
]
}
}
You may not hard-code the list of “parentheses” characters. How input is given is not specified, though; this could be either command-line arguments or via standard input, as you wish.
./program 'p' 'q' <<< '1p23p45q67q8'
Or does it need only support{[(<
and}])>
? \$\endgroup\$