untitled2014gd 2020-06-13 17:59 采纳率: 0%
浏览 602

语法错误 : 缺少“;”(在“类型”的前面)这个怎么解

#include
#include

#define overflow -1
#define ok 1
#define error 0
#define maxsize 100
#define stackincrement 10
typedef char SElemType;
typedef int Status;

typedef struct
{
SElemType *base;
SElemType *top;
int StackSize;
}SqStack;

Status InitStack(SqStack *S)
{
S->base=(SElemType *)malloc(maxsize*sizeof(SElemType));
if(!S->base)
exit(overflow);
S->top=S->base;
S->StackSize=maxsize;
return ok;
}

Status getTop(SqStack S,SElemType e)
{
if(S.top==S.base)
return error;
*e=
(S.top-1);
return ok;
}

Status Push(SqStack S,SElemType e)
{
if(S->top-S->base>=S->StackSize)
{
S->base=(SElemType
)realloc(S->base,(S->StackSize+stackincrement)*sizeof(SElemType));
if(!S->base)
exit(overflow);
S->StackSize+=stackincrement;
}
*(S->top)=e;
(S->top)++;
return ok;
}

Status Pop(SqStack S,SElemType *e)
{
if(S->top==S->base)
return error;
*e=
(--S->top);
return ok;
}

Status StackEmpty(SqStack S)
{
if(S.top==S.base)
return ok;
else
return error;
}

void match(char *ch)
{
SqStack S;
char *p;
char e;
InitStack(&S);
p=ch;
while(p&&(*p!='\0'))
{
switch (*p)
{
case'(':{Push(&S,*p);p++;printf("左括号(进栈成功\n");break;}
case'[':{Push(&S,*p);p++;printf("左括号[进栈成功\n");break;}
case'{':{Push(&S,*p);p++;printf("左括号}进栈成功\n");break;}
case')':
{
if(!StackEmpty(S))
{
getTop(S,&e);
if(e=='(')
{ printf("括号)匹配成功!\n");Pop(&S,&e);p++;}
else
{ printf("括号)不匹配!\n");Pop(&S,&e);p++; }
}
else
{printf("右括号)是多余的!\n");Pop(&S,&e);p++;
break;
};
case']':
{
if(!StackEmpty(S))
{
getTop(S,&e);
if(e=='[')
{ printf("括号]匹配成功!\n");Pop(&S,&e);p++;}
else
{ printf("括号]不匹配!\n");Pop(&S,&e);p++; }
}
else
{printf("右括号]是多余的!\n");Pop(&S,&e);p++;}
case'}':
{
if(!StackEmpty(S))
{
getTop(S,&e);
if(e=='{')
{ printf("括号}匹配成功!\n");Pop(&S,&e);p++;}
else
{ printf("括号}不匹配!\n");Pop(&S,&e);p++; }
}
else
{printf("右括号}是多余的!\n");Pop(&S,&e);p++;}
break;
};
default:p++;
}

}
if(StackEmpty(S))
{
printf("匹配正确");
}
else
{
printf("匹配失败");
}
}

int main()
{

while(1)
{
char ch[50];
printf("请输入要进行判断的括号字符串:");
gets(ch);
match(ch);
}
}

e:\vs2012\data\shiyan\shiyan\shiyan.c(137): error C2143: 语法错误 : 缺少“;”(在“类型”的前面)

  • 写回答

2条回答 默认 最新

  • qtchen_1988 2020-06-13 18:06
    关注

    你这代码很多{} 跟 标点符号不对,你要好好检查

    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料