-
Notifications
You must be signed in to change notification settings - Fork 0
/
proc1.c
44 lines (35 loc) · 882 Bytes
/
proc1.c
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
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <signal.h>
struct point {
double x, y;
};
/* A vector is an array of points. N is the number of points, and p points to the first point in the array.
*/
struct vector {
int n;
struct point *p;
};
/* A binary tree of vectors, ordered by KEY. */
struct tree {
struct tree *left, *right;
int key;
struct vector *vector;
};
/* Return the node in TREE whose key is KEY. Return zero if there if no such node. */
struct tree *
find (struct tree *tree, int key)
{
if (! tree)
return 0;
if (key < tree->key)
return find (tree->left, key);
else if (key > tree->key)
return find (tree->right, key);
else
return tree;
}
int main (int argc, char **argv)
{
struct sigaction new_action, old_action;