-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFormula.h
34 lines (27 loc) · 863 Bytes
/
Formula.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#ifndef _FORMULA_H_
#define _FORMULA_H_
#include <string>
#include <vector>
#include "Stack.hpp"
using namespace std;
class FormulaAnalyzer{
string formula;
vector<string> variableArr;
vector<string> targetArr;
public:
FormulaAnalyzer( string s, vector<string> v, vector<string> t );
~FormulaAnalyzer();
int calculate( vector<int> valueArr, string formulas[] );
private:
/* replace target to f(variable) such as a=bc d=ab */
string replaceTarget( string s, string formulas[] );
/* add '*' and expand formula */
string standard_form( string s );
/* infix to posifix */
string postfixExpression( string s );
/* check if the first str is variable */
string find_first_var( string standerd );
/* see each var wheather 0 or 1 */
int get_value_of_var(string a, vector<int> valueArr );
};
#endif