描述現在,有一行括號序列,請你檢查這行括號是否配對。

 
輸入
第一行輸入一個數N(0<N<=100),表示有N組測試資料。後面的N行輸入多組輸入資料,每組輸入資料都是一個字串S(S的長度小於10000,且S不是空串),測試資料組數少於5組。資料保證S中只含有"[","]","(",")"四種字元
輸出
每組輸入資料的輸出佔一行,如果該字串中所含的括號是配對的,則輸出Yes,如果不配對則輸出No
樣例輸入
3
[(])
(])
([[]()])
樣例輸出
No
No
Yes
#include <stdio.h>
#include <string.h>
#define M 10001
char s[M], s1[M];//s是目標陣列,s1是棧
int main()
{
int n, len, top, i;
scanf("%d", &n);
while(n--){ top = ;//棧頂
scanf("%s", s+);
len = strlen(s+);
for(i = ; i <= len; i++){ s1[top++] = s[i];//入棧
while(s1[top-] - s1[top-] == || s1[top-] - s1[top-] == )//這裡用while是處理【】()等相鄰的情況
{
top -= ;//出棧
} }
if(top <= )
printf("Yes\n");
else
printf("No\n");
}
return ;
}

疑問: 有top小於3的情況嗎?