Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.07 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<string.h>
  4.  
  5. #define True 1
  6. #define False 0
  7. #define T 100
  8.  
  9. typedef struct fila{
  10.     char azul[T];
  11.     fila *prox;
  12. }fi;
  13.  
  14. void create(fi **fil){
  15.     (*fil) = NULL;
  16. }
  17. void enqueue(fi **fil, char azul[]){
  18.     fi *aux,*novo;
  19.     novo = (fi*)malloc(sizeof(fi));
  20.     novo -> prox = NULL;
  21.     strcmp(novo -> azul, azul);
  22.     if(isempty(*fil) == True)
  23.         (*fil) = novo;
  24.     else{
  25.         aux = (*fil);
  26.         do{
  27.             aux = aux -> prox;
  28.         }while(aux -> prox != NULL);
  29.         aux -> prox = novo;
  30.     }
  31. }
  32. fila *dequeue(fi **fil){
  33.     fi *aux = *fil;
  34.     if(isempty(*fil) == True){
  35.         printf("Nao existe nada a ser preparado.\n");
  36.         return NULL;
  37.     }
  38.     else{
  39.         (*fil) = (*fil)->prox;
  40.         aux -> prox = NULL;
  41.         return aux;
  42.     }
  43. }
  44. fila *head(fi *fil){
  45.     return fil;
  46. }
  47. int isempty(fi *fil){
  48.     if(fil == NULL)
  49.         return True;
  50.     return False;
  51. }
  52. int isfull(fi *fil){
  53.     return False;
  54. }
  55. void destroy(fi **fil){
  56.     fi *aux;
  57.     if(isempty(*fil)==True)
  58.         free(*fil);
  59.     else{
  60.         aux = (*fil);
  61.         do{
  62.             (*fil) = (*fil) -> prox;
  63.             free(aux);
  64.             aux = (*fil);
  65.         }while((*fil) != NULL);
  66.     }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement