labrab24

 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#include <iostream>
using namespace std;
typedef enum DataType {INTEGER, FLOAT, VARIABLE, OPERATION};
class UniData
{
DataType type;
union
{
int intData;
float floatData;
char * varData;
};
};
template< class Type >
class Node
{
protected:
Type data;
unsigned int weight;
Node * up;
Node * left;
Node * right;
public:
Node()
{
weight = 0;
up = NULL;
left = NULL;
right = NULL;
}
Node(Type d1, unsigned int w1)
{
data = d1;
weight = w1;
up = NULL;
left = NULL;
right = NULL;
}
Node * Add(Node * nn)
{
if (nn->weight < weight)
{
if (up)
return up->Add(nn);
else
return nn->Add(this);
}
else
{
if (left)
{
if (right)
return NULL;
else
{
nn->up = this;
right = nn;
return right;
}
}
else
{
nn->up = this;
left = nn;
return left;
}
}
}
void Print()
{
left->Print();
right->Print();
char str[16];
cout << data.GetAsStr(str);
}
};
int main()
{
char input[] = "(a+b)*(c+d)+a*d";
cout << "Hello world!" << endl;
return 0;
}