-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtree.cpp
59 lines (46 loc) · 1.1 KB
/
tree.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
58
59
//
// Created by antronyx on 03/02/19.
//
#include "tree.h"
#include <math.h>
#include <zconf.h>
#include <fstream>
void nspace(int n) {
int i = 0;
while (i < n) {
cout << " ";
i++;
}
}
void Person::printTree(Person *p, int indent) {
if (p != NULL) {
if (p->father) {
printTree(p->father, indent + 4);
}
if (indent) {
std::cout << std::setw(indent) << ' ';
}
if (p->father) std::cout << " /\n" << std::setw(indent) << ' ';
std::cout << p->name << "\n ";
if (p->mother) {
std::cout << std::setw(indent) << ' ' << " \\\n";
printTree(p->mother, indent + 4);
}
}
}
Person::Person() {
}
void Person::printFather() {
if (this->father != NULL)
cout << this->father->getName();
}
void Person::printMother() {
if (this->mother != NULL) {
cout << this->mother->getName();
}
}
void Person::printSimple() {
cout << this->name << endl;
if (father != NULL) this->father->printSimple();
if (mother != NULL) this->mother->printSimple();
}