1 + 3-2 这是我从文件中读取并尝试评估的表达式 当做1 + 3我得到我的临时指针+和temp->前面有值1并且一切正常然后我得到4-2但是当我评估这个并得到我的临时指针 - temp-> previous显示垃圾值而不是显示4 .....请帮助
void evaluate(list *temp, char operator)
{
temp = head;
while (temp != nullptr)
{
if (temp->next->operatorval == operator)
{
if (oper == '/')
temp->previous->floatval = temp->previous->floatval / temp->next->floatval;
else if (oper == '*')
temp->previous->floatval = temp->previous->floatval * temp->next->floatval;
else if (oper == '+')
temp->previous->floatval = temp->previous->floatval + temp->next->floatval;
else if (oper == '-')
temp->previous->floatval = temp->previous->floatval - temp->next->floatval;
temp = temp->previous;
removeNext(temp, temp->next, 1);
removeNext(temp, temp->next, 2);
}
temp = temp->next;
}
}