代码:
#include<iostream>
using namespace std;
#include<map>
#include<stack>
char s[1010];
map<char, char>mp;
int main()
{
mp['<'] = '>';
mp['{'] = '}';
mp['('] = ')';
mp['['] = ']';
while (cin >> s)
{
stack<char >st;
for (int i = 0; i < strlen(s); i++)
{
if (st.empty())st.push(s[i]);
else
{
if (s[i] == mp[st.top()])
{
st.pop();
}
else
{
st.push(s[i]);
}
}
}
if (st.empty())cout << "yes";
else cout << "no";
}
return 0;
}