#include<iostream>
using namespace std;
int main()
{
int a,c,d,i;
string b;
while(cin>>d)
{ cin.ignore();
while(d--)
{ i=0;
getline(cin,b);
a=c=0;
while(b[i])
{
if (b[i]=='(')
a++;
if (b[i]==')')
a--;
if (b[i]=='[')
c++;
if (b[i]==']')
c--;
if((a<0)||(c<0))break;
i++;
}
if((a==0)&&(c==0))
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
}
}
return 0;
}
#include
using namespace std;
int main()
{
int a,c,d,i;
string b;
while(cin>>d)
{ cin.ignore();
while(d--)
{ i=0;
getline(cin,b);
a=c=0;
while(b[i])
{
if (b[i]=='(')
a++;
if (b[i]==')')
a--;
if (b[i]=='[')
c++;
if (b[i]==']')
c--;
if((a<0)||(c<0))break;
i++;
}
if((a==0)&&(c==0))
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
}
}
return 0;
}
#include
using namespace std;
int main()
{
int a,c,d,i;
string b;
while(cin>>d)
{ cin.ignore();
while(d--)
{ i=0;
getline(cin,b);
a=c=0;
while(b[i])
{
if (b[i]=='(')
a++;
if (b[i]==')')
a--;
if (b[i]=='[')
c++;
if (b[i]==']')
c--;
if((a<0)||(c<0))break;
i++;
}
if((a==0)&&(c==0))
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
}
}
return 0;
}
程式漏洞:(([)]) :Yes 解答應為No