Problem Description
括号配对问题
Time limit: 3000 msMemory limit: 128 MB
Description
Given a line of bracket sequence, check whether the brackets in this line are matched.
Input
The first line contains a number N (0<N<=100), indicating there are N groups of test data. The following N lines contain multiple groups of input data, each group is a string S (the length of S is less than 10000, and S is not an empty string); the number of test data groups is fewer than 5. The data guarantees that S contains only four characters: “[”, “]”, “(”, “)”.
Output
Each group of input data produces one line of output. If the brackets contained in the string are matched, output Yes; if not matched, output
Sample Input
| |
Sample Output
| |
Source
Problem Analysis
Use a stack to check whether they correspond
cpp
| |