本文实例为大家分享了C语言简易计算器的具体代码,供大家参考,具体内容如下
主要解决了处理负数、小数等的基础运算操作,无图形界面
#include <iostream>
#include <stack>
using namespace std;
class Calculator{
private:
int Priority(char fuhao);
double CalSuffix(string PostfixExp);
public:
double Calculate(string InfixExp);
string InfixToSuffix(string InfixExp);
};
double Calculator::CalSuffix(string PostfixExp){
double tmpresult,ch1,ch2;
double tmpnum,tmpxiaoshu=1;
int i=0,tmpdashu;
int isfu=0; ///
stack<double> stk2;
while(PostfixExp[i]!='