Skip to content

Commit

Permalink
adicionando uma funcao extra para devs: cod. 1518
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaian-k committed Jun 26, 2022
1 parent b8aa7f1 commit 7db0a9c
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 25 deletions.
26 changes: 13 additions & 13 deletions abb.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,6 @@ Abb_node *remover_abb(Abb_node *root, int id){
free(root); return aux;}}}}


void node_imprimir(int id, int espaco) { //funcao aux da: abb_exibir_estrutura
for (int i=0; i<espaco; i++){printf(" ");}
printf("(%d)\n", id);}
//exibe a estrutura da abb de forma grafica
void abb_exibir_estrutura(Abb_node *node, int espaco) {
if (node == NULL) {
node_imprimir(-1, espaco); return;}

abb_exibir_estrutura(node->right, espaco+1);
node_imprimir(node->id, espaco);
abb_exibir_estrutura(node->left, espaco+1);}


void in_ordem(Abb_node *aux){
if (aux != NULL){
if (aux->left != NULL){in_ordem(aux->left);}
Expand All @@ -94,3 +81,16 @@ void in_ordem(Abb_node *aux){
if (aux->right != NULL){in_ordem(aux->right);}}

else {printf("Não foi encontrada nenhuma encomenda pendente.\n\n");}}


void node_imprimir(int id, int espaco) { //funcao aux da: abb_exibir_estrutura
for (int i=0; i<espaco; i++){printf(" ");}
printf("(%d)\n", id);}
//exibe a estrutura da abb de forma grafica
void abb_exibir_estrutura(Abb_node *node, int espaco) {
if (node == NULL) {
node_imprimir(-1, espaco); return;}

abb_exibir_estrutura(node->right, espaco+1);
node_imprimir(node->id, espaco);
abb_exibir_estrutura(node->left, espaco+1);}
18 changes: 9 additions & 9 deletions fuctions_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,18 @@ void encomendar(){
else {
new->id = id;

// printf("Digite o nome do aluno:\n");
// char *nome_aluno = malloc(sizeof(char)); scanf(" %[^\n]s", nome_aluno);
// new->nome_aluno = nome_aluno;
printf("Digite o nome do aluno:\n");
char *nome_aluno = malloc(sizeof(char)); scanf(" %[^\n]s", nome_aluno);
new->nome_aluno = nome_aluno;

//... matricula e descricao.. Dados iniciais da encomenda de um livro
// printf("Digite a matricula do aluno:\n");
// int matricula; scanf("%d", &matricula);
// new->matricula = matricula;
printf("Digite a matricula do aluno:\n");
int matricula; scanf("%d", &matricula);
new->matricula = matricula;

// printf("Escreva a descricao do livro:\n");
// char *descricao = malloc(sizeof(char)); scanf(" %[^\n]s", descricao);
// new->descricao = descricao;
printf("Escreva a descricao do livro:\n");
char *descricao = malloc(sizeof(char)); scanf(" %[^\n]s", descricao);
new->descricao = descricao;

new->left = NULL; new->right = NULL;
add_abb(new, aux, id);}}
Expand Down
Binary file modified principal
Binary file not shown.
13 changes: 10 additions & 3 deletions principal.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@


int main(){
int resp; printf("\nSISTEMA DE ENCOMENDA DE LIVRO\n");
//create variables
int resp;

while (resp != 0){
printf("\nSISTEMA DE ENCOMENDA DE LIVRO\n");
printf(" 1 - Encomendar um livro.\n"
" 2 - Remover uma encomenda de livro.\n"
" 3 - Remover um pedido de livro.\n"
Expand All @@ -17,16 +19,21 @@ int main(){

switch (resp){
case 1: //encomendar um livro
encomendar(); mostraArvore(root, 1); break;
encomendar(); break;

case 2:
remover_encomenda(); break;

case 3:
break;

case 1815: //OPCAO ESPECIAL (Ada Lovelace - reference)
printf("\n\n===Exibir estrutura da ABB (Graficamente)===\n\n");
abb_exibir_estrutura(root, 1);
printf("\n============================================\n\n\n"); break;

default:
break;}}
printf("\n\nSelecione uma opção valida!\n\n"); break;}}

return 0;}

Expand Down

0 comments on commit 7db0a9c

Please sign in to comment.