求助,为什么下面的程序运算出来之后不能进行连乘除的运算
#include <stdio.h>#include <stdlib.h>
char quanvoid match(char logo);
int low(void);
int mid(void);
int high(void);
void match(char logo)
{
if(quan==logo)
quan=getchar();
else
{
printf("不能匹配\n");
exit(1);
}
}
int low(void)
{
float result=mid();
while((quan=='+')||(quan=='-'))
if(quan=='+')
{
match('+');
result+=mid();
break;
}
else if(quan=='-')
{
match('-');
result-=mid();
break;
}
return result;
}
int high(void)
{
int result;
if(quan=='(')
{
match('(');
result=low();
match(')');
}
else if(quan>='0'&&quan<='9')
{
ungetc(quan,stdin);
scanf("%d",&result);
quan=getchar();
}
else
{
printf("bu识别字符");
exit(1);
}
return result;
}
int mid(void)
{
int div;
int result=high();
while((quan=='*')||(quan=='/'))
if(quan=='*')
{
match('*');
result*=high();
break;
}
else if(quan=='/')
{
match('/');
div=high();
if(div==0)
{
printf("除数为0\n");
exit(1);
}
result/=div;
break;
}
return result;
}
//主程序
int main()
{
int result;
printf("欢迎使用简单计算器\n");
printf("请输入需计算的式子\n");
quan=getchar();
result=low();
if(quan=='\n')
printf("答案是%d\n",result);
else
{
printf("不识别字符");
exit(1);
}
scanf("%d",&result);
return 0;
}