Skip to content

Commit

Permalink
funcao de add com prioridade na fila (concluido)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaian-k committed Jun 28, 2022
1 parent eb4b8f9 commit 256840c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 10 deletions.
5 changes: 3 additions & 2 deletions fila_pre_cadastrados.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
#include <stdlib.h>


//secretarios e transportadora
//3 secretarios e 5 transportadora
typedef struct admin {
char *nome;
char *email;
char *senha;
int cpf;
int cargo;
char cargo;
} Admin;


Expand Down
23 changes: 19 additions & 4 deletions fila_prioridade.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,25 @@ void add_fila(int identificador, char *nome_aluno, int prioridade){
if (fifop_start == NULL){ //fila vazia
fifop_start = novo; fifop_last = novo; fifop_tam++;}

else { //adiciona de acordo com a prioridade! :D
//modificar!
fifop_last->next = novo;
fifop_last = novo; fifop_tam++;}}
//adiciona de acordo com a prioridade! :D
else if(fifop_start->p->prioridade < prioridade){
novo->next = fifop_start;
fifop_start = novo; fifop_tam++;}

else {
if (fifop_last->p->prioridade > prioridade){
fifop_last->next = novo;
fifop_last = novo;}

else {
Fifop_node *aux = fifop_start;
while (aux->next->p->prioridade < prioridade){
aux = aux->next;}

novo->next = aux->next;
aux->next = novo;}

fifop_tam++;}}


void imprimir(){
Expand Down
13 changes: 9 additions & 4 deletions principal.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ int main(){
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"
printf("\n===SISTEMA DE ENCOMENDA DE LIVRO===\n\n");
printf(" 1 - Encomendar um livro.\n" //sem senha
" 2 - Remover uma encomenda de livro.\n" //secretario
" 3 - Adicionar um pedido de livro.\n" //secretario
" 4 - Remover um pedido de livro.\n" //transportadora
" 0 - Sair do sistema!\n"
"Digite a funcionalidade desejada: "); scanf("%d", &resp);

Expand All @@ -22,11 +23,15 @@ int main(){
encomendar(); break;

case 2:
//validacao: cpf e senha
remover_encomenda(); break;

case 3:
break;

case 4:
break;

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

0 comments on commit 256840c

Please sign in to comment.