//
#include<bits/stdc++.h>
using namespace std;
bool f( const char& x,const char& y )
{
string s; s+=x; s+=y;
if( s=="()" || s=="[]" || s=="{}" )
return true;
else
return false;
}
int main()
{
stack<char> sk;
string s;
int i;
while( getline( cin,s ) )
{
while( !sk.empty() ) sk.pop();
for( i=0;i<s.size();i++ )
{
if( !sk.empty() && f( sk.top(),s[i] ) ) sk.pop();
else sk.push( s[i] );
}
if( sk.empty() ) cout<<"yes"<<endl;
else cout<<"no"<<endl;
}
return 0;
}
VJ_S - Sequence of brackets_stack
猜你喜欢
转载自blog.csdn.net/qq_63173957/article/details/124615238
今日推荐
周排行