C语言表达式计算器
为了方便了解流程,在程序中把计算过程也输出了.而且栈操作的实现部分也是自己实现的.程序用两个栈,optr寄存运算符,opnd寄存操作数和运算结果.输入的表达式以等号结束,例如:2*(1+2)=
/**************表达式计算器************/
#include <stdio.h>
#include <stdlib.h>hQ!Sq)o
#include <string.h>y*b.KCqv
#include <conio.h> j"s,]lA~$ti~W8kQ
#include <malloc.h>
+M4l"OJ1y7[7y
#define STACK_SIZE 100)M7dA$q!kk7^
#define APPEND_SIZE 10
9o5{Y Qg].O7x
struct SNode{]X9_[OX
float data; /*存放操作数或者计算结果*/+{h5q St X
char ch; /*存放运算符*/
};
h"eJL4g @
struct Stack{6\+g|/O5US
SNode *top;
SNode *base;Ou|| Py@Htu*Nb4w0{
int size;gX-z-?}_N M1^6_
};