-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
57 lines (42 loc) · 2.03 KB
/
main.cpp
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <iostream>
#include <iomanip>
#include "AlgebraicExpression.h"
using namespace::std;
int main(int argc, const char * argv[]) {
cout << infix2postfix("(3 +5) -8*4") << endl;
cout << infix2postfix("1 + 2 * 3 + ( 4 * 5 + 6 ) * 7") << endl;
cout << evaluatePostfix("653-8*+2/") << endl;
cout << infix2postfix("3+4*2/(1-5)") << endl;
// cout << evaluatePostfix("3+4*2/(1-5)") << endl;
cout << infix2postfix("(1+2)*(3+4)") << endl;
// cout << evaluatePostfix("(1+2)*(3+4)") << endl;
cout << endl;
cout << infix2postfix("1-2+3") << endl;
cout << infix2postfix("1/(2*3)") << endl;
cout << infix2postfix("(1+2)*3") << endl;
cout << infix2postfix("1-(2+3)") << endl;
cout << infix2postfix("1-(2/3*4)") << endl;
cout << infix2postfix("1/2/3-(4+5)*6") << endl;
cout << infix2postfix("1*(2/3/4)+5") << endl;
cout << infix2postfix("1-(2+3*4)/5") << endl;
cout << endl;
cout << evaluatePostfix("12-3+") << endl;
cout << evaluatePostfix("123*/") << endl;
cout << evaluatePostfix("12+3*") << endl;
cout << evaluatePostfix("123+-") << endl;
cout << evaluatePostfix("123/4*-") << endl;
cout << evaluatePostfix("12/3/45+6*-") << endl;
cout << evaluatePostfix("123/4/*5+") << endl;
cout << evaluatePostfix("1234*+5/-") << endl;
cout << evaluatePostfix("653-8*+2/") << endl;
cout << infix2postfix("(5+3)-2*(6+1)-1*(7+3)/3+(4/2)") << endl;
cout << evaluatePostfix(infix2postfix("(5+3)-2*(6+1)-1*(7+3)/3+(4/2)"))<<endl;
cout<< infix2postfix("(2-3+4)*(5+6*7)") << endl;
cout<< evaluatePostfix(infix2postfix("(2-3+4)*(5+6*7)"))<< endl;
cout << infix2postfix ("(3+5)-8*4") << endl ;//35+84*-
cout << fixed << setprecision(2) << evaluatePostfix ("653-8*+2/") << endl;//11.00
cout << fixed << setprecision(2) << evaluatePostfix ("52/3*") << endl;//7.50
cout << infix2postfix ("(5/2)*3") << endl ;//52/3*
cout << fixed << setprecision(2) << evaluatePostfix (infix2postfix ("3-2*2")) << endl;//-1.00
return 0;
}