double answer()
{
char ch;
char theta;double a,b;
int v=0;
OPTR OPTR;
linkstack OPND;
Initlinkstack(&OPND);
pushchar(&OPTR,'#');
printf("请输入表达式并以#结尾:");
scanf_s("%c",&ch);
Gettopchar(OPTR,&theta);
while(ch!='#'&&theta!='#'){
if(judgment(ch)!=1)
{
int temp;
temp=ch-'0';
ch=getchar();
while(judgment(ch)!=1)
{
temp=temp*10+ch-'0';
ch=getchar();
}
pushnum(&OPND,temp);
}
else{
Gettopchar(OPTR,&theta);
switch(precede(theta,ch))
{
case'<':
pushchar(&OPTR,ch);ch=getchar();break;
case'=':
popchar(&OPTR,&ch);ch=getchar();break;
case'>':
popchar(&OPTR,&ch);popnum(&OPND,&a);popnum(&OPND,&b);
pushnum(&OPND,calculate(a,theta,b));break;
}
}
}
while(popchar(&OPTR,&ch)!=0)
{
v=v*10+ch-'0';
}
return v;
}
int main()
{
double i;
i=answer();
printf("%f",i);
return 0;
}
这两个函数有算法上的错误吗?