#include<iostream>
#include<stdlib.h>
using namespace std;
#define MAXSIZE 10
char data[MAXSIZE]={0}; //定义数组
int top=0; //标记数组,和栈的指针作用相同
bool bracketCheck(char str[],int length){
for(int i=0;i<length;i++){
if(str[i]=='('||str[i]=='['||str[i]=='{'){
data[top]=str[i];
top++;
}else{
if(top==0){
cout<<"top==0"<<endl;
return false;
}else{
char c=data[--top];
if(str[i]==')'&&c!='('){
return false;
}
if(str[i]==']'&&c!='['){
return false;
}
if(str[i]=='}'&&c!='{'){
return false;
}
}
}
if(top==0){
return true;
}
}
}
int main(){
char str[]={'{','[','(','(',')',')',']','}'};
if(bracketCheck(str,7)){
cout<<"匹配成功"<<endl;
}else
cout<<"匹配失败"<<endl;
return 0;
}