This repository has been archived by the owner on May 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTree.h
64 lines (58 loc) · 1.35 KB
/
Tree.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
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
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
#ifndef NODE_H
#define NODE_H
enum c_type
{
Number,
Sign,
Varible,
Function
};
class CNode
{
private:
c_type type;
double num;
char sign;
char var;
string func;
CNode* left;
CNode* right;
public:
CNode();
CNode(double val);
CNode(char t_var);
CNode(char data, CNode* t_left, CNode* t_right);
CNode(string, CNode* t_left);
~CNode();
c_type GetType() { return type; }
double GetNum() { return num; }
char GetSign() { return sign; }
char GetVar() { return var; }
string GetFun() { return func; }
CNode* GoLeft() { return left; }
CNode* GoRight() { return right; }
void GoDump(int tab);
friend CNode* derivate(const CNode*);
friend CNode* const_optimization(const CNode*);
};
class tree_print {
std::ofstream output;
void print_equation_(CNode* tree);
void print_data_(CNode* tree, int special_characters=0);
void print_tree_(CNode* tree);
//ofstream create_tex();
public:
tree_print(const char*);
~tree_print();
void equation(CNode* tree);
void tree(CNode* tree);
};
#endif