-->
当前位置:首页 > 题库

PROGRAMMING:Bracket matching problem

Luz5年前 (2021-05-10)题库409
###Task description
```
There are left brackets, right brackets and uppercase and lowercase letters in a string (length no more than 100);
It is stipulated that any left bracket matches the nearest right bracket to its right from inside to outside.
Write a program, find the unmatched left bracket and right bracket, output the original string, and mark the unmatched bracket in the next line. The unmatched left bracket is marked with "$", and the unmatched right bracket is marked with "?" tagging.
```
###Input format:
```
The input includes multiple groups of data, one line for each group, including a string, only left and right brackets and upper and lower case letters, and the length of the string does not exceed 100.
```
###Output format:
```
For each group of output data, output two lines, the first line contains the original input characters, and the second line is composed of "$", "?" And spaces, "$" and " Indicates that the corresponding left bracket and right bracket cannot match.
```
###Input example:
```in
((ABCD(x)
)(rttyy())sss)(
```
###Output example:
```out
((ABCD(x)
$$
)(rttyy())sss)(
? ?$
```
###Title Source
Website http://noi.openjudge.cn/ch0202/2705/ , selected from openjudge website, question number: 2705.







answer:If there is no answer, please comment