blob: f9d6585cd591f80a093cf46d8d35de17f3fc9aa1 (
plain)
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
|
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
typedef struct node {
int id;
struct node *left;
struct node *right;
} treenode;
main (argc, argv, envp)
int argc;
char **argv, **envp;
{
treenode *a, *b, *c, *d, *z;
z = malloc(sizeof(treenode));
z->id = 'z';
z->left = 0;
z->right= 0;
d = malloc(sizeof(treenode));
d->id = 'd';
d->left = 0;
d->right= 0;
c = malloc(sizeof(treenode));
c->id = 'c';
c->left = d;
c->right= z;
b = malloc(sizeof(treenode));
b->id = 'b';
b->left = 0;
b->right= 0;
a = malloc(sizeof(treenode));
a->id = 'a';
a->left = b;
a->right= c;
/* manually create nodes to build this tree:
a
/ \
b c
/ \
d z
*/
}
|