// Determine whether the input bracket format is correct ( It's limited to brackets and brackets )
【 Input 】
[[([()])]]
【 Output 】
YES
#include<iostream>
#include<cstring>
using namespace std;
char b[101];
int top=0;
void push(char x){
if(top<101){
top++;
b[top]=x;
return;
}
cout<<" Stack failed "<<endl;
}
void pop(){
if(top>0){
top--;
return;
}
cout<<" Stack out failed "<<endl;
}
int main(){
char a[101];
cin.getline(a,101);
for(int i=0;i<strlen(a);i++){
if(a[i]=='('||a[i]=='[') push(a[i]);
else if(b[top]=='('&&a[i]==')') pop();
else if(b[top]=='['&&a[i]==']') pop();
else cout<<"NO"<<endl;
}
if(top==0)cout<<"YES"<<endl;
return 0;
}