计算器代码无法实现运算
# include<stdio.h>
char token;
void match(char expectedToken)
{if(token==expectedToken) token=getchar();
else
{printf("cannot match\n");
exit(1);
}
}
int low(void)
{int result=mid();
while((token=='+')||(token=='_'))
if(token=='+')
{match('+');q
result+=mid();
break;
}
else if(token=='-')
{match('-');
result-=mid();
break;
}
return result;
}
int mid(void)
{int div;
int result=high();
while((token=='*')||(token=='/'))
if(token=='*')
{match('*');
result*=high();
break;
}
else if(token=='/')
{ match('/');
div=high();
if(div==0)j
{ printf("the dived is 0\n");
exit(1);
}
我是一名初学者,这是计算器代码,复杂的四则运算运行无结果。我想计算器中有时间显示的功能,怎么做?