括号匹配
#include<iostream>
#include<stack>
#include<string>
using namespace std;
int main() {
string str;
stack<char> s;
while (cin >> str) {
for (int i = 0; i < str.length(); i++) {
if (str[i] == '(' || str[i] == '['||str[i] == '{')
s.push(str[i]);
if (str[i] == ')' || str[i] == ']' || str[i] == '}') {
char c = s.top();
if ((str[i] == ')'&&c == '(') || (str[i] == ']'&&c == '[') || (str[i] == '}'&&c == '{')) {
s.pop();
}
else
{
break;
}
}
}
if (s.empty()) {
cout << "Yes" << endl;
}
else
{
cout << "No" << endl;
}
}
}