[Html] <SPAN style = "FONT-SIZE: 14px"> parentheses matching problem time limit: 3000 MS | memory limit: 65535 KB difficulty: 3 Description now, there is a sequence of parentheses, check whether this line of parentheses is paired. Enter N (0 <N <= 100) In the first line, indicating that N groups of test data exist. The next N rows Input Multiple groups of input data. Each group of input data is a string of S (the length of S is less than 10000, and S is not an empty string), and the number of test data groups is less than five. Data guarantee S only contains "[", "]", "(", ")" and outputs each group of input data to occupy one row, if the parentheses contained in the string are paired, Yes is output. If not paired, No is output. Input 3 [(]) ([[] ()]) sample output No Yes </SPAN> bracket pairing problem time limit: 3000 MS | memory limit: 65535 KB difficulty: 3 Description now, there is a sequence of parentheses, check whether this line of parentheses is paired. Enter N (0 <N <= 100) In the first line, indicating that N groups of test data exist. The next N rows Input Multiple groups of input data. Each group of input data is a string of S (the length of S is less than 10000, and S is not an empty string), and the number of test data groups is less than five. Data guarantee S only contains "[", "]", "(", ")" and outputs each group of input data to occupy one row, if the parentheses contained in the string are paired, Yes is output. If not paired, No is output. Input 3 [(]) ([[] ()]) sample output NoNoYes [cpp] <SPAN style = "FONT-SIZE: 14px" >#include <cstdio >#include <stack >#include <cstring> using namespace std; int main () {int test; // freopen ("D: // ACMInput/input.txt", "r", stdin); scanf ("% d", & test ); while (test --) {stack <char> number; char c [10050]; scanf ("% s", c); int flag = 0; if (strlen (c) % 2 = 1) {Printf ("No \ n"); continue;} while (! Number. empty () {number. pop () ;}for (int I = 0; I <strlen (c); I ++) {if (c [I] = '[' | c [I] = '(') {number. push (c [I]);} else if (c [I] = ']') {if (! Number. empty () {char c = number. top (); number. pop (); if (c = '[') {continue;} else flag = 1;} else flag = 1;} else if (c [I] = ') ') {if (! Number. empty () {char c = number. top (); number. pop (); if (c = '(') {continue;} else flag = 1;} else flag = 1;} if (flag = 1) break ;} if (flag = 1) printf ("No \ n"); else printf ("Yes \ n") ;}return 0 ;} </SPAN> # include <cstdio> # include <stack> # include <cstring> using namespace std; int main () {int test; // freopen ("D: // ACMInput/input.txt "," r ", stdin); scanf (" % d ", & test); while (test --) {stack <char> number; char c [1 0050]; scanf ("% s", c); int flag = 0; if (strlen (c) % 2 = 1) {printf ("No \ n "); continue;} while (! Number. empty () {number. pop () ;}for (int I = 0; I <strlen (c); I ++) {if (c [I] = '[' | c [I] = '(') {number. push (c [I]);} else if (c [I] = ']') {if (! Number. empty () {char c = number. top (); number. pop (); if (c = '[') {continue;} else flag = 1;} else flag = 1;} else if (c [I] = ') ') {if (! Number. empty () {char c = number. top (); number. pop (); if (c = '(') {continue;} else flag = 1;} else flag = 1;} if (flag = 1) break ;} if (flag = 1) printf ("No \ n"); else printf ("Yes \ n") ;}return 0 ;}