标签:
#include <stdio.h>
#include <string.h>
char a[10005],b[10005];
int main()
{
int len,top,n,i,j,k;
scanf("%d",&n);
while(n--)
{
scanf("%s",&a);
len=strlen(a);
if(len%2!=0)
printf("No\n");
else
{
if(a[0]==')'||a[0]==']')
printf("No\n");
top=1;
b[0]=a[0];
for(i=1;i<len;i++)
{
b[top]=a[i];
if(top==0)
top++;
else
{
if(b[top-1]=='('&&b[top]==')')
top--;
else if(b[top-1]=='['&&b[top]==']')
top--;
else
top++;
}
}
if(top==0)
printf("Yes\n");
else
printf("No\n");
}
}
return 0;
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:
原文地址:http://blog.csdn.net/dxx_111/article/details/47099349