-
Notifications
You must be signed in to change notification settings - Fork 981
/
Copy pathmain.cpp
50 lines (45 loc) · 990 Bytes
/
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
#include <iostream>
#include "solution.h"
#include <vector>
void print(TreeLinkNode *root)
{
while (root)
{
std::cout << root->val;
TreeLinkNode *cur = root->next;
while (cur)
{
std::cout << "->" << cur->val;
cur = cur->next;
}
std::cout << std::endl;
while (root->next && !root->left) root = root->next;
root = root->left;
}
}
int main(int argc, char** argv)
{
TreeLinkNode root(-2);
TreeLinkNode node1(-9);
TreeLinkNode node2(0);
TreeLinkNode node3(3);
TreeLinkNode node4(5);
TreeLinkNode node5(-1);
TreeLinkNode node6(9);
TreeLinkNode node7(-6);
TreeLinkNode node8(-1);
TreeLinkNode node9(8);
root.left = &node1;
root.right = &node2;
node1.left = &node3;
node2.left = &node4;
node2.right = &node5;
node3.left = &node6;
node5.left = &node7;
node7.left = &node8;
node7.right = &node9;
Solution s;
s.connect(&root);
print(&root);
return 0;
}