23栈的应用-根据后缀表达式求值
Posted luanxin
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了23栈的应用-根据后缀表达式求值相关的知识,希望对你有一定的参考价值。
main.c
#define _CRT_SECURE_NO_WARNING #include<stdio.h> #include<stdlib.h> #include<string.h> #include"Stack.h" //判断是不是数字 int IsNumber1(char c) { return c >= ‘0‘ && c <= ‘9‘; } typedef struct MYNUM { StackNode node; int val; }MyNum; int Caculate(int left,int right,char c) { int ret = 0; switch (c) { case‘+‘: ret = left + right; break; case‘-‘: ret = left - right; break; case‘*‘: ret = left*right; break; case‘/‘: ret = left / right; break; default: break; } return ret; } int main() { char* str = "831-5*+"; char* p = str; LinkStack* stack = InitStack(); while (*p!=‘