#include
#include
#include
#include
//判断运算符的优先级函数
int Precede(char a, char b)
{
switch (a)
{
case '*':
case '/':
if ((b == '+') || (b == '-'))
{
return 1; //a的优先级高于b
}
else
{
return 0; //a的优先级等于b
}
case '+':
case '-':
if ((b == '*') || (b == '/'))
{
return -1; //a的优先级低于b
}
else
{
return 0;
}
default:
printf("运算符错误!\n");
break;
}
}
int Operate(int j, int k, char operater)
{
switch (operater)
{
case '+':
return k + j;
//break;
case '-':
return k - j;
//break;
case '*':
return k * j;
//break;
case '/':
return k / j;
//break;
default: printf("运算错误!\n");
break;
}
}
int calculate(int len, char *expStr)
{
//表达式异常处理,注意len