Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <stdbool.h>
- #define MAX_PISTAS 3
- typedef struct No {
- int pista[MAX_PISTAS],size;
- struct No *prox;
- }fila;
- fila *fila_cria(void)
- {
- fila *f = (fila *) malloc(sizeof(fila));
- if (f != NULL)
- f->prox = NULL;
- return f;
- }
- bool isEmpty(fila *f)
- {
- return(f->prox == NULL);
- }
- bool enfileirar(fila *f,int p,int v)
- {
- fila *no = (fila *) malloc(sizeof(fila));
- if (no == NULL)
- fprintf(stderr,"erro");
- no->pista[ p ] = v;
- no->prox = NULL;
- if (isEmpty(f))
- no->prox = no;
- else
- no->prox = no;
- no->prox =no;
- f->size++;
- return true;
- }
- void imprime(fila *f)
- {
- printf("[ %d ] ",f->pista[0 ]);
- }
- int main()
- {
- fila *f=fila_cria();
- enfileirar(f,0,3);
- imprime(f);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement