标签:class div string tab ble int c table sp har amp
3 [(]) (]) ([[]()])
No No Yes
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<string>
#include<stack>
#include<algorithm>
using 
namespace std;
int main(int argc, char* argv[])
{
	int 
n;
	cin>>n;
	while(n--)
	{
char 
c[10005];
		cin>>c;
		int i,flag=1;
		stack<char> 
s;
		for(i=0;c[i];i++)
		{
			if(c[i]==‘(‘||c[i]==‘[‘)
				s.push(c[i]);
			else 
if(s.empty())
			{	flag=0;  	break;}
			else 
if((c[i]==‘)‘&&s.top()==‘(‘)||(c[i]==‘]‘&&s.top()==‘[‘))
			{	s.pop();	}
			else
			{ 
flag=0; 
break;}
		}
		if(s.empty()&&flag)	cout<<"Yes"<<endl;
		else	cout<<"No"<<endl;
	}
 
   return 0;
}
标签:class div string tab ble int c table sp har amp
原文地址:http://www.cnblogs.com/52Cyan/p/3698065.html