-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path124-main.c
More file actions
40 lines (36 loc) · 757 Bytes
/
124-main.c
File metadata and controls
40 lines (36 loc) · 757 Bytes
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
#include <stdlib.h>
#include <stdio.h>
#include "binary_trees.h"
/**
* print_array - Prints an array of integers
*
* @array: The array to be printed
* @size: Size of the array
*/
void print_array(const int *array, size_t size)
{
size_t i;
for (i = 0; i < size; ++i)
printf("(%03d)", array[i]);
printf("\n");
}
/**
* main - Entry point
*
* Return: 0 on success, error code on failure
*/
int main(void)
{
avl_t *tree;
int array[] = {
1, 2, 20, 21, 22, 32, 34, 47, 62, 68,
79, 84, 87, 91, 95, 98
};
size_t n = sizeof(array) / sizeof(array[0]);
tree = sorted_array_to_avl(array, n);
if (!tree)
return (1);
print_array(array, n);
binary_tree_print(tree);
return (0);
}