#包含
#包含
#define STACK_INIT_SIZE 100
#define高个子长颈鹿10
#定义溢出- 2
#定义信息可启用- 1
#define ERROR 0
#定义ok 1
typedef char fqdbd;
类型结构
{
fqdbd *base;
fqdbd *top;
int stacksize;
}SqStack;
intinitstack(HPdstsq )。
{
sq-base=(hsdjd ) malloc ) stack_init_size*sizeof ) FQDBD );
if (! Sq-base (退出)溢出;
sq-top=sq-base;
sq-stacksize=STACK_INIT_SIZE;
返回确定;
}
intgettop(HPdstsq,hsdjd e ) )。
{
if(sq-base==sq-top )返回错误器;
返回确定;
} //GetTop
intpush(HPdstsq,fqdbd e ) )。
{
if(sq-top-sq-base=sq-stacksize ) )。
{
sq-base=(hsdjd ) realloc ) sq-base,(sq-stacksize高长颈鹿) sizeof ) FQDBD ) );
if (! Sq-base (退出)溢出;
sq-top=sq-base sq-stacksize;
sq-stacksize=高个子长颈鹿;
}
返回确定;
}//Push
intpop(HPdstsq,hsdjd e ) )。
{
if(sq-base==sq-top )返回错误器;
返回确定;
}//Pop
intclear(HPdstsq,fqdbd e ) )。
{
sq-top=sq-base;
返回确定;
}//Clear
intstackempty(HPdstsq ) )。
{
if(sq-base==sq-top )返回确定;
else返回错误;
}//堆栈事件
防毒墙网络版(fqdbdch,fqdbd str ) )。
{
if(ch=='(str==' ) ) ) ) )返回确定;
elseif(ch=='['str=='] ' )返回确定;
elseif(ch=='{'str=='} ' )返回确定;
else返回错误;
}
语音广播(Fq DBD * str ) )。
{
SqStack S;
int i;
char ch;
for(I=0; str[i]!='# '; I )
{
(sitch(str[I] ) ) ) ) ) ) ) )。
{
case'(: )
case '[':
case '{':
推送(s,str[i];
布雷克;
case ' ) ' :
case ']':
case '}':
堆叠深度(s ) )
{
printf ()/n右括号有多馀! /n '; 返回;
}
else
{
gttop(s,ch );
if(match(ch,str[i] ) ) pop (s,ch );
else
{
printf ()/n左右括号不一致! /n '; 返回;
}
}//else
}//交换机
}//for
堆叠深度(s ) )
printf ()/n匹配成功! /n ';
else
printf ()/n左括号有多馀! /n ';
}//BracketMatch
void main ()//输入以“#”结束int i; char ch; char str[100]; gets(str ); Bracketmatch(str[0]; }