#include<iostream>
using namespace std;
#include<string>
class SeqStack
{
public :
SeqStack(){top=-1;}
~SeqStack(){}
void Push(char x);
char Pop();
private :
int data[20];
int top;
};
void SeqStack::Push(char x)//P
{
top++;
data[top]=x;
}
char SeqStack::Pop()//D
{
int t;
t=top;
top--;
return data[t];
}
int main()
{
SeqStack A;
int n,i,count=0;
string a;
cin>>a;
n=();
if(n%2==1)
cout<<"no"<<endl;
else
{
for(i=0;i<n;i++)
{
if(a[i]=='(')
{
a[i]=')';
(a[i]);
}
else if(a[i]=='[')
{
a[i]=']';
(a[i]);
}
else if(a[i]=='{')
{
a[i]='}';
(a[i]);
}
else if(a[i]==')')
{
if(a[i]==())
count++;
}
else if(a[i]==']')
{
if(a[i]==())
count++;
}
else
{
if(a[i]==())
count++;
}
}
if(count==n/2)
cout<<"yes"<<endl;
else
cout<<"no"<<endl;
}
return 0;
}
C 括号匹配 数据结构 来自淘豆网m.daumloan.com转载请标明出处.