Advertisement
luciana1237

Untitled

Jul 20th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.82 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <stdbool.h>
  4.  
  5. typedef struct No {
  6.     int x;
  7.     struct No *inicio;
  8.     struct No *fim;
  9.     struct No *prox;
  10. }fila;
  11.  
  12. fila *fila_cria(void)
  13. {
  14.     fila *f = (fila *) malloc(sizeof(fila));
  15.    
  16.     if (f != NULL)
  17.         f->inicio = NULL;
  18.         f->fim = NULL;
  19.     return f;
  20. }
  21.  
  22. bool isEmpty(fila *f)
  23. {
  24.     return (f->inicio == NULL);
  25. }
  26.  
  27. bool enfileirar(fila *f,int v)
  28. {
  29.     fila *no = (fila *) malloc(sizeof(fila));
  30.     fila *p;
  31.     if (no == NULL)
  32.         fprintf(stderr,"erro");
  33.        
  34.     no->x=v;
  35.     no->prox = NULL;
  36.    
  37.     if (isEmpty(f)){
  38.         printf("fila vazia");
  39.         p->inicio = no;
  40.     }else
  41.         p->fim->prox = no;
  42.    
  43.     p->fim = no;
  44.     return true;
  45. }
  46.  
  47. int main()
  48. {
  49.     fila *f= fila_cria();
  50.     enfileirar(f,3);
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement