⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 evaluate.h

📁 计算器程序
💻 H
字号:
//****************************************************************
//This software may not be distributed further without permission from
// Sun Xueshi's Group
//      
//This software is distributed WITHOUT ANY WARRANTY. No claims are made
// as to its functionality or purpose.
// 
//Authors: 孙学诗
// Date: 12/4/03
// 
//****************************************************************

#ifndef EVALUATE_H
#define EVALUATE_H

#include<string>
#include<cstdlib>
#include<cassert>
#include <stdio.h>
#include"Stack.h"

using namespace std;

const char Operators[10] = "%^+-*/()#=";          //Define operators

class Evaluate {
	public:
		Evaluate();
		~Evaluate() {fclose(stream);}
		void Run();                                            //Do evaluate expression
		void Interface(FILE *stream);              //Get stream contain expression that is input
		string GetResult();                               //Change result to proper form of string
		bool IsOperator(char ch);                    //If character is operator, return ture
	private:
		void GetInput();                                   //Get input from a stream
		int InStackPriority(char ch);                //Get In Stack Priority
		int InComingPriority(char ch);            //Get In Comint Priority
		double DoOperator(double left, char op, double right);       //evaluate with two operands and a operator 
		Stack<char> Optr;                               //Define a char Stack to save Operator characters
		Stack<double> Opnd;                          //Define a double Stack to save Operand characters
		FILE *stream;                                      //Define a file stream 
		char Operator;
		double Operand;		
		double LeftOpnd, RightOpnd;
		double Result;
		int DivideByZero;                                //If zero is divisor, DivideByZero=1, default DivideByZero=0
		string ResultText;                                //use string to save result
};
#endif

	

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -