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