Knowledge: The string is automatically added after the end of the acceptance. With scanf ("%s", &s), there is a problem with the function input string, that is, if a space is entered to assume that the string ends, the character after the space is processed as the next entry, but the Get () function will receive the entire string of input until it encounters a change in behavior.
SCANF cannot read carriage return and storage
SCANF cannot accept space, Tab tab, carriage return, etc.; And get can accept space, Tab tab and enter, etc.;
The scanf touches the null character in the buffer (Space, tab, enter, the newline will be truncated and added), and the get is to wait for the carriage return to truncate the string and add the
For example, "Hello world!" string length is 12 (the string is stored with the end of the auto-plus character) if you write "Hello \0world!" string length is 6 (space is also counted as a character)
sprintf (A, "%2.2s", a); The first 2 indicates that the resulting string is not more than 2 characters, and if the last one is populated with a string terminator, the second 2 means up to 2 characters in the subsequent string.
Now, with a sequence of parentheses, you should check that the line brackets are paired.
-
Input
-
The first line enters a number n (0<n<=100), which indicates that there are n sets of test data. The next n lines enter multiple sets of input data, each set of input data is a string s (S is less than 10000, and S is not an empty string), and the number of test data groups is less than 5 groups. Data guarantee S contains only "[", "]", "(", ")" Four characters
-
Output
The
-
output of each set of input data is one row, and if the parentheses contained in the string are paired, the output is yes, and no is output if not paired. First:
-
the premise of pairing: the number of characters must be an even number
of
-
second: first and N pairs
-
second and N-1 pairs
-
Loop end condition is j-i==1
Pair of brackets