#T352. 扩号匹配问题
扩号匹配问题
Description
In a given string (with length not exceeding 100), there are left parentheses, right parentheses, and uppercase/lowercase letters. The rule (same as common arithmetic expressions) is that any left parenthesis matches with the closest right parenthesis to its right, from the innermost to the outermost. Write a program to identify unmatched left and right parentheses. Output the original string on the first line, and mark the unmatched parentheses on the second line. Unmatched left parentheses should be marked with "$", and unmatched right parentheses should be marked with "?".
Input Format
The input consists of multiple test cases. Each test case is a single line containing a string composed of left/right parentheses and uppercase/lowercase letters. The string length does not exceed 100.
Output Format
For each test case, output two lines. The first line contains the original input string. The second line consists of "" and "?" indicate the corresponding unmatched left and right parentheses, respectively.
((ABCD(x)
)(rttyy())sss)(
((ABCD(x)
$$
)(rttyy())sss)(
? ?$