前缀表达式问题
写了一个递归的前缀表达式求解,结果总是0:
char *a="*+7**46+895";
int i;
int eval()
{ int x = 0;
while (a[i] == ' ') i++;
if (a[i] == '+')
{ i++; return eval() + eval(); }
if (a[i] == '*')
{ i++; return eval() * eval(); }
while ((a[i] >= '0') && (a[i] <= '9'))
x = 10*x + (a[i++]-'0');
return x;
}
main()
{
int re;
re=eval();
printf("re is %d",re);
system("pause");
}
请大大们帮忙看看