C语言表达式计算器
为了方便了解流程,在程序中把计算过程也输出了.而且栈操作的实现部分也是自己实现的.eTZ-d@5}程序用两个栈,optr寄存运算符,opnd寄存操作数和运算结果.输入的表达式以等号结束,例如:2*(1+2)=
/**************表达式计算器************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>O,nH!eKB{F
#include <malloc.h>X1h2S'N(V0?Z{
#define STACK_SIZE 100
#define APPEND_SIZE 10
struct SNode{
float data; /*存放操作数或者计算结果*/
char ch; /*存放运算符*/
};
*l9X+L5{ b'z9q
struct Stack{
SNode *top;[%cVbZ8x'v
SNode *base;tX5k(G*y-Wj
int size;,R-uL"y$f9x|
};
}W:e/Sf'hx'R5l
/*栈操作函数*/
int InitStack(Stack &S); /*创建栈*/