#include <stdio.h>
#include <stdlib.h>
struct no {
int dado;
struct no *prox;
};
typedef struct no criano;
typedef criano *no_pont;
int tam;
//void cria_Fila(no_pont *head, no_pont *tail);
int fila_Vazia(no_pont head);
void insere_Fila(no_pont *head, no_pont *tail, int valor);
int retira_Fila(no_pont *head, no_pont *tail);
void imprime_Fila(no_pont atual);
int main() {
no_pont head=NULL;
no_pont tail=NULL;
insere_Fila(&head, &tail, 52);
insere_Fila(&head, &tail, 21);
insere_Fila(&head, &tail, 532);
imprime_Fila(head);
return 0;
}
int fila_Vazia(no_pont head) {
return head==NULL;
}
void insere_Fila(no_pont *head, no_pont *tail, int valor) {
no_pont novo;
novo
= (no_pont
)malloc(sizeof(criano
));
if(novo!=NULL) {
novo->dado=valor;
novo->prox=NULL;
if(fila_Vazia(*head)) {
*head=novo;
} else {
(*tail)->prox=novo;
}
*tail = novo;
} else {
printf("%d nao inserido. Nao ha espaco na memoria\n",valor
); }
tam++;
}
void imprime_Fila(no_pont atual) {
if(atual == NULL) {
printf("A fila esta vazia\n"); } else {
while(atual!=NULL) {
atual=atual->prox;
}
}
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCnN0cnVjdCBubyB7CiAgICBpbnQgZGFkbzsKICAgIHN0cnVjdCBubyAqcHJveDsKfTsKCnR5cGVkZWYgc3RydWN0IG5vIGNyaWFubzsKdHlwZWRlZiBjcmlhbm8gKm5vX3BvbnQ7CmludCB0YW07CgovL3ZvaWQgY3JpYV9GaWxhKG5vX3BvbnQgKmhlYWQsIG5vX3BvbnQgKnRhaWwpOwppbnQgZmlsYV9WYXppYShub19wb250IGhlYWQpOwp2b2lkIGluc2VyZV9GaWxhKG5vX3BvbnQgKmhlYWQsIG5vX3BvbnQgKnRhaWwsIGludCB2YWxvcik7CmludCByZXRpcmFfRmlsYShub19wb250ICpoZWFkLCBub19wb250ICp0YWlsKTsKdm9pZCBpbXByaW1lX0ZpbGEobm9fcG9udCBhdHVhbCk7CgppbnQgbWFpbigpIHsKICAgIG5vX3BvbnQgaGVhZD1OVUxMOwogICAgbm9fcG9udCB0YWlsPU5VTEw7CiAgICBpbnNlcmVfRmlsYSgmaGVhZCwgJnRhaWwsIDUyKTsKICAgIGluc2VyZV9GaWxhKCZoZWFkLCAmdGFpbCwgMjEpOwogICAgaW5zZXJlX0ZpbGEoJmhlYWQsICZ0YWlsLCA1MzIpOwogICAgaW1wcmltZV9GaWxhKGhlYWQpOwoKICAgIHJldHVybiAwOwp9CgppbnQgZmlsYV9WYXppYShub19wb250IGhlYWQpIHsKICAgIHJldHVybiBoZWFkPT1OVUxMOwp9Cgp2b2lkIGluc2VyZV9GaWxhKG5vX3BvbnQgKmhlYWQsIG5vX3BvbnQgKnRhaWwsIGludCB2YWxvcikgewogICAgbm9fcG9udCBub3ZvOwogICAgbm92byA9IChub19wb250KW1hbGxvYyhzaXplb2YoY3JpYW5vKSk7CgogICAgaWYobm92byE9TlVMTCkgewogICAgICAgIG5vdm8tPmRhZG89dmFsb3I7CiAgICAgICAgbm92by0+cHJveD1OVUxMOwoKICAgICAgICBpZihmaWxhX1ZhemlhKCpoZWFkKSkgewogICAgICAgICAgICAqaGVhZD1ub3ZvOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICgqdGFpbCktPnByb3g9bm92bzsKICAgICAgICB9CgogICAgICAgICp0YWlsID0gbm92bzsKICAgIH0gZWxzZSB7CiAgICAgICAgcHJpbnRmKCIlZCBuYW8gaW5zZXJpZG8uIE5hbyBoYSBlc3BhY28gbmEgbWVtb3JpYVxuIix2YWxvcik7CiAgICB9CiAgICB0YW0rKzsKfQoKdm9pZCBpbXByaW1lX0ZpbGEobm9fcG9udCBhdHVhbCkgewogICAgaWYoYXR1YWwgPT0gTlVMTCkgewogICAgICAgIHByaW50ZigiQSBmaWxhIGVzdGEgdmF6aWFcbiIpOwogICAgfSBlbHNlIHsKICAgICAgICBwcmludGYoIkEgZmlsYSBlOiAiKTsKCiAgICAgICAgd2hpbGUoYXR1YWwhPU5VTEwpIHsKICAgICAgICAgICAgcHJpbnRmKCIlZCAgIixhdHVhbC0+ZGFkbyk7CiAgICAgICAgICAgIGF0dWFsPWF0dWFsLT5wcm94OwogICAgICAgIH0KCiAgICAgICAgcHJpbnRmKCJOVUxMXG5cbiIpOwogICAgfQp9Cg==