标签:style blog class code java color
#include <iostream> #include <stack> #include <string> using namespace std; int main() { int n;cin>>n; while(n--){ stack<char> s; string str;cin>>str; for(int i=0;i!=str.length();i++){ if(s.empty()) s.push(str[i]); else{ if(s.top()==‘(‘){ if(str[i]==‘)‘) s.pop(); else s.push(str[i]);} else if(s.top()==‘[‘){ if(str[i]==‘]‘) s.pop(); else s.push(str[i]); } else {s.push(str[i]);} } } if(s.empty()) cout<<"Yes"<<endl; else cout<<"No"<<endl; } return 0; }
标签:style blog class code java color
原文地址:http://www.cnblogs.com/xzenith/p/3712530.html