C语言表达式计算器
为了方便了解流程,在程序中把计算过程也输出了.而且栈操作的实现部分也是自己实现的.(B,B9`*L(M+]l程序用两个栈,optr寄存运算符,opnd寄存操作数和运算结果.输入的表达式以等号结束,例如:2*(1+2)=
/**************表达式计算器************/7k c2g*Dh5l5E
#include <stdio.h>4lzcm8Lq(v
#include <stdlib.h>~,gZ?2fvhM&L
#include <string.h>
#include <conio.h>
#include <malloc.h>hLkL-_gd:NUQ-c&c
]5{4r)e.Iry6l7?+r
#define STACK_SIZE 100
#define APPEND_SIZE 10J-_a`1TsG
m w|5O4g`LD|:[
struct SNode{)lg{8J$w7A
float data; /*存放操作数或者计算结果*/8i,~N_CJ7nj
char ch; /*存放运算符*/xg&a*y t8Xo ?
};
!` f1b9O1kY8hId
struct Stack{
SNode *top;
SNode *base;