Skip to content

Commit

Permalink
arrumando o remover, agr remove tanto com 1 filho e com 2 filhos
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaian-k committed Jun 30, 2022
1 parent ce80c69 commit b81464e
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 42 deletions.
3 changes: 2 additions & 1 deletion .vscode/dryrun.log
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
make --dry-run --always-make --keep-going --print-directory
make: Entering directory '/home/lukaian/Desktop/trabalhos_faculdade/trabalho_de_ED'
make: Leaving directory '/home/lukaian/Desktop/trabalhos_faculdade/trabalho_de_ED'

make: *** No targets specified and no makefile found. Stop.

make: Leaving directory '/home/lukaian/Desktop/trabalhos_faculdade/trabalho_de_ED'

24 changes: 12 additions & 12 deletions .vscode/targets.log
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ make: *** No rule to make target 'all'. Stop.
# This is free software: you are free to change and redistribute it.
# There is NO WARRANTY, to the extent permitted by law.

# Make data base, printed on Wed Jun 29 10:54:15 2022
# Make data base, printed on Thu Jun 30 12:34:13 2022

# Variables

Expand All @@ -21,7 +21,7 @@ NO_AT_BRIDGE = 1
# environment
GJS_DEBUG_OUTPUT = stderr
# environment
VSCODE_IPC_HOOK_EXTHOST = /run/user/1000/vscode-ipc-1da8cd07-0a52-4110-80c2-5523bca56290.sock
VSCODE_IPC_HOOK_EXTHOST = /run/user/1000/vscode-ipc-c3f50e32-2734-4b1e-8dae-016792327f3e.sock
# environment
VSCODE_CWD = /home/lukaian
# environment
Expand Down Expand Up @@ -63,7 +63,7 @@ VSCODE_CODE_CACHE_PATH = /home/lukaian/.config/Code/CachedData/30d9c6cd9483b2cc5
# environment
LANG = C
# environment
XAUTHORITY = /run/user/1000/.mutter-Xwaylandauth.F8J5N1
XAUTHORITY = /run/user/1000/.mutter-Xwaylandauth.CL75N1
# default
.LOADED :=
# default
Expand Down Expand Up @@ -101,13 +101,13 @@ MAKEFILE_LIST :=
# environment
VSCODE_VERBOSE_LOGGING = true
# environment
VSCODE_PID = 6068
VSCODE_PID = 26198
# environment
XDG_SESSION_TYPE = wayland
# automatic
?D = $(patsubst %/,%,$(dir $?))
# environment
SESSION_MANAGER = local/unix:@/tmp/.ICE-unix/1693,unix/unix:/tmp/.ICE-unix/1693
SESSION_MANAGER = local/unix:@/tmp/.ICE-unix/1685,unix/unix:/tmp/.ICE-unix/1685
# automatic
*F = $(notdir $*)
# environment
Expand Down Expand Up @@ -145,7 +145,7 @@ MAKEFILES :=
# automatic
^F = $(notdir $^)
# environment
INVOCATION_ID = 7cd236e1d3c74aab861a85e213a3862c
INVOCATION_ID = b1a38313f06a483ebb8f9a99673e2465
# environment
VSCODE_LOG_NATIVE = false
# environment
Expand Down Expand Up @@ -175,7 +175,7 @@ GIO_LAUNCHED_DESKTOP_FILE = /usr/share/applications/code.desktop
# makefile
.DEFAULT_GOAL :=
# environment
SYSTEMD_EXEC_PID = 1751
SYSTEMD_EXEC_PID = 1737
# environment
HISTCONTROL = ignoredups
# environment
Expand All @@ -187,19 +187,19 @@ USER = lukaian
# default
MAKE_VERSION := 4.3
# environment
MANAGERPID = 1562
MANAGERPID = 1569
# environment
which_declare = declare -f
# environment
DEBUGINFOD_URLS = https://debuginfod.fedoraproject.org/
# environment
GIO_LAUNCHED_DESKTOP_FILE_PID = 6068
GIO_LAUNCHED_DESKTOP_FILE_PID = 26198
# environment
_ = /usr/bin/make
# environment
XDG_RUNTIME_DIR = /run/user/1000
# environment
JOURNAL_STREAM = 8:27605
JOURNAL_STREAM = 8:29466
# environment
XDG_SESSION_CLASS = user
# environment
Expand Down Expand Up @@ -235,7 +235,6 @@ GDMSESSION = gnome

# . (device 35, inode 2172841): 12 files, no impossibilities.


# 12 files, no impossibilities in 1 directories.

# Implicit Rules
Expand Down Expand Up @@ -286,12 +285,13 @@ GNUmakefile:

# No general ('VPATH' variable) search path.


# strcache buffers: 1 (0) / strings = 20 / storage = 210 B / avg = 10 B
# current buf: size = 8162 B / used = 210 B / count = 20 / avg = 10 B

# strcache performance: lookups = 23 / hit rate = 13%
# hash-table stats:
# Load=20/8192=0%, Rehash=0, Collisions=0/23=0%
# Finished Make data base on Wed Jun 29 10:54:15 2022
# Finished Make data base on Thu Jun 30 12:34:13 2022


41 changes: 24 additions & 17 deletions abb.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,37 @@ void add_abb(Abb_node *new, Abb_node *aux, int id){


Abb_node *remover_abb(Abb_node *root, int id){
if (root == NULL){return NULL;}
if (root == NULL){
printf("Valor nao encontrado!\n"); return NULL;}

else {
if (root->left, root->right == NULL){ //remove nós, caso nao tenha filhos
free(root); printf("Elemento removido!\n\n"); return NULL;}
else { //procura o nó a remover
if (root->id == id){ //remove nós, caso nao tenha filhos
if (root->left == NULL && root->right == NULL){
free(root); return NULL;}

else { //remove nós, caso tenha 1 ou 2 filhos
if (root->left, root->right != NULL){ //com 2 filhos
Abb_node *aux = root->left;
while (aux->right != NULL){
aux = aux->right;}
else { //remove nós, caso tenha 1 ou 2 filhos
if (root->left != NULL && root->right != NULL){ //com 2 filhos
Abb_node *aux = root->left;

root->id = aux->id;
aux->id = id;
while (aux->right != NULL){
aux = aux->right;}

root->left = remover_abb(root->left, id); return root;}
root->id = aux->id;
aux->id = id;

else { //com 1 filho
Abb_node *aux;
root->left = remover_abb(root->left, id);
return root;}

if (root->left != NULL){aux = root->left;}
else {aux = root->right;}
else { //com 1 filho
Abb_node *aux;
if (root->left != NULL){aux = root->left;}
else {aux = root->right;}

free(root); return aux;}}}}
free(root); return aux;}}}

else {
if (id < root->id){root->left = remover_abb(root->left, id);}
else {root->right = remover_abb(root->right, id);} return root;}}}


void in_ordem(Abb_node *aux){
Expand Down
3 changes: 2 additions & 1 deletion fila_pre_cadastrados.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ Fifopre_node *fifopre_start = NULL; Fifopre_node *fifopre_last = NULL; int fifop
//fuctions

void fifopre_add(int identificador, char *nome_aluno, int prioridade){
Pedido *p = malloc(sizeof(Pedido));
Admin *admin = malloc(sizeof(Admin));

p->identificador = identificador;
p->nome_aluno = nome_aluno;
p->prioridade = prioridade;
Expand Down
33 changes: 22 additions & 11 deletions fuctions_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,28 @@ void remover_encomenda(){

int retorno = verificar_senha();
if (retorno == 1){
int selecionar_id;
printf(" Digite o id da encomenda que deseja remover:\n"); scanf("%s", &selecionar_id);
root = remover_abb(root, selecionar_id);

//setar novos dados (faltando)
char *nome_responsavel; char *nome_campus_aluno; char *nome_campus_livro;
printf(" Digite o nome do responsavel:\n"); scanf(" %[^\n]s", nome_responsavel);
printf(" Digite o nome do campus do aluno:\n"); scanf(" %[^\n]s", nome_campus_aluno);
printf(" Digite o nome do campus do livro:\n"); scanf(" %[^\n]s", nome_campus_livro);
//5 - add_fila(....);
}}
//create variables
int selecionar_id; Abb_node *lixo = buscar(selecionar_id, root);

printf(" Digite o id da encomenda que deseja remover:\n"); scanf("%d", &selecionar_id);

if (lixo != NULL){
root = remover_abb(root, selecionar_id);

//setar novos dados (faltando)
printf("Digite o nome do responsavel:\n");
char *nome_responsavel = malloc(sizeof(char)); scanf(" %[^\n]s", nome_responsavel);

printf("Digite o nome do campus do aluno:\n");
char *nome_campus_aluno = malloc(sizeof(char)); scanf(" %[^\n]s", nome_campus_aluno);

printf("Digite o nome do campus do livro:\n");
char *nome_campus_livro = malloc(sizeof(char)); scanf(" %[^\n]s", nome_campus_livro);

printf("Informe a prioridade do pedido (0 à 100):\n");
int prioriadade; scanf("%d", &prioriadade);

add_fila(lixo->id, prioriadade, lixo->nome_aluno, lixo->matricula, lixo->descricao, nome_responsavel, nome_campus_aluno, nome_campus_livro);}}}


void remover_pedido(){
Expand Down
Binary file modified principal
Binary file not shown.

0 comments on commit b81464e

Please sign in to comment.