Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- #include<string.h>
- #define True 1
- #define False 0
- #define T 100
- typedef struct fila{
- char azul[T];
- fila *prox;
- }fi;
- void create(fi **fil){
- (*fil) = NULL;
- }
- void enqueue(fi **fil, char azul[]){
- fi *aux,*novo;
- novo = (fi*)malloc(sizeof(fi));
- novo -> prox = NULL;
- strcmp(novo -> azul, azul);
- if(isempty(*fil) == True)
- (*fil) = novo;
- else{
- aux = (*fil);
- do{
- aux = aux -> prox;
- }while(aux -> prox != NULL);
- aux -> prox = novo;
- }
- }
- fila *dequeue(fi **fil){
- fi *aux = *fil;
- if(isempty(*fil) == True){
- printf("Nao existe nada a ser preparado.\n");
- return NULL;
- }
- else{
- (*fil) = (*fil)->prox;
- aux -> prox = NULL;
- return aux;
- }
- }
- fila *head(fi *fil){
- return fil;
- }
- int isempty(fi *fil){
- if(fil == NULL)
- return True;
- return False;
- }
- int isfull(fi *fil){
- return False;
- }
- void destroy(fi **fil){
- fi *aux;
- if(isempty(*fil)==True)
- free(*fil);
- else{
- aux = (*fil);
- do{
- (*fil) = (*fil) -> prox;
- free(aux);
- aux = (*fil);
- }while((*fil) != NULL);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement