-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
80 lines (74 loc) · 2.07 KB
/
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
#include <malloc.h>
#include "Arvore.h"
//Mikaelly S
int main(){
arv *T;
int opcao, info, noPai;
criarVazia(&T);
menu();
scanf("%d", &opcao);
system("clear");
while (opcao !=0){
//Inserir raiz
if (opcao == 1){
printf("Digite o valor da raiz: ");
scanf("%d", &info);
if (inserirRaiz(&T,info))
printf("Raiz inserida");
else
printf("Raiz não inserida");
} else if (opcao == 2) { //Inserir filho esquerdo
printf("Digite o valor do nó pai: ");
scanf("%d", &noPai);
printf("Digite o valor do nó filho: ");
scanf("%d", &info);
if (inserirEsq(T,noPai,info))
printf("Nó filho inserido");
else
printf("Nó filho não foi inserido");
} else if (opcao == 3) { //Inserir filho direito
printf("Digite o valor do nó pai: ");
scanf("%d", &noPai);
printf("Digite o valor do nó filho: ");
scanf("%d", &info);
if (inserirDir(T,noPai,info))
printf("Nó filho inserido");
else
printf("Nó filho não foi inserido");
} else if (opcao == 4) { //Verificar se a árvore tem algum nó
printf("Digite o valor do nó: ");
scanf("%d", &info);
if (procura(T, info))
printf("A árvore tem esse nó");
else
printf("A árvore não tem esse nó");
} else if (opcao == 5) { //Exibir o pai de um nó
printf("Digite o valor do nó: ");
scanf("%d", &info);
exibirPai(T,info);
} else if (opcao == 6) { //Exibir os filhos de um nó
printf("Digite o valor do nó: ");
scanf("%d", &info);
exibirFilhos(T,info);
} else if (opcao == 7) { //Exibir o filho direito
printf("Digite o valor do nó: ");
scanf("%d", &info);
exibirFilhoDireito(T,info);
} else if (opcao == 8) { //Exibir o filho esquerdo
printf("Digite o valor do nó: ");
scanf("%d", &info);
exibirFilhoEsquerdo(T,info);
} else if (opcao == 9){ //Remover um nó folha
printf("Digite o valor do nó: ");
scanf("%d", &info);
removerNo(T,info);
}
menu();
scanf("%d", &opcao);
system("clear");
}
return 0;
}