文章
17
粉丝
166
获赞
6
访问
143.7k
#include <bits/stdc++.h>
using namespace std;
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
{
char cur = st.top();
if(s[i] == mp[cur])
st.pop();
else st.push(s[i]);
}
}
if(st.empty()) cout << "yes" << endl;
else cout << "no" << endl;
}
return 0;
}
登录后发布评论
暂无评论,来抢沙发