-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmain.c
47 lines (35 loc) · 966 Bytes
/
main.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
45
46
47
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include "rbt.h"
#define MAX 10
int main() {
TNoRB *arvore = NULL;
int opc = -1, flag = 1, n, rn;
do {
printf("1 - Inserir elemento;\n2 - Remover elemento;\n3 - Ver árvore;\n4 - Sair\n");
scanf("%d", &opc);
switch(opc) {
case 1:
printf("Elemento a inserir:\n");
scanf("%d", &n);
insereNo(&arvore, NULL, &arvore, n);
break;
case 2:
printf("Elemento a remover:\n");
scanf("%d", &rn);
removeNo(&arvore, rn);
break;
case 3:
inOrder(arvore);
break;
case 4:
flag = 0;
break;
default:
printf("Opção inválida.\n");
}
printf("==========\n");
} while (flag);
return 0;
}