关于括号匹配的算法,试了挺多答案,不知道错在哪里

int check()
{
listack *s;
char ch[80],*p,e; int j=0;
initstack(s);
getchar();
gets(ch);
int i=strlen(ch);
while(j<i )
{
switch(ch[j])
{
case '(':
case '[':
case '{':{push(s,ch[j]); j++;}
break;
case ')':
case ']':
case '}':
if(!stackempty(s))
{
e=pop(s);
if(!(e=='('&& ch[j]==')'||e=='['&& ch[j]==']'||e=='{'&& ch[j]=='}'))
{
return 0;
}
}
else
return 0;
default: j++;
}
}
if(stackempty(s))
return 1;
else
return 0;
}