帮忙检查问题 明明程序能运行 结果上传的网上说有问题 看看哪出问题了
#include
#include
#define size 100
typedef struct
{
char *base;
char *top;
}sqstack;
void initstack(sqstack &s)
{
s.base=(char*)malloc(size*sizeof(char));
s.top=s.base;
}
char gettop(sqstack s)
{
char e;
e=*(s.top-1);
return e;
}
void push(sqstack &s,char e)
{
(*s.top++)=e;
}
void pop(sqstack &s)
{
s.top=s.top-1;
}
void qingchu(sqstack &s)
{
s.top=s.base;
}
int main()
{
sqstack s;
initstack(s);
int i,j,k,c[100];
char b[100],e;
scanf("%d",&j);
for(k=0;k<j;k++)
{
scanf("%s",b);
push(s,b[0]);
for(i=1;b[i];i++)
{
if(b[i]=='['||b[i]=='(')
{
push(s,b[i]);
continue;
}
else
e=gettop(s);
if((b[i]==']'&&e=='[')||(b[i]==')'&&e=='('))
pop(s);
else
break;
}
if(s.top==s.base)
c[k]=1;
else
c[k]=2;
qingchu(s);
}
for(k=0;k<j;k++)
{
if(c[k]==1)
printf("Yes\n");
else
printf("No\n");
}
return 0;
}