#ifndef COLA_H_INCLUDED
#define COLA_H_INCLUDED
#include <stdio.H>
#include <conio.h>
#include <stdlib.h>
typedef char letra;
typedef struct Nodo{
letra elem;
Nodo *sig;
};
typedef Nodo* apt;
struct cola{
apt frente,final;
}c;
typedef Nodo *posicion;
typedef int logico;
void inicializa(apt *C) {
*C=new(Nodo);
(*C)->sig=NULL;
c.frente=NULL;
c.final=NULL;
}
void inserta(letra x, apt C){
posicion aux,aux2;
aux=new Nodo;
aux->elem=x;
aux->sig=NULL;
aux2=C;
while(aux2->sig!=NULL)
aux2=aux2->sig;
aux2->sig =aux;
c.final=aux;
if(c.frente==NULL)
c.frente=aux;
}
logico vacia(apt C){
if (C->sig==NULL)
return 1;
else
return 0;
}
void suprimir(apt C){
posicion aux;
if (vacia(C))
printf("Cola Vacia");
else{
aux=C->sig->sig;
delete(C->sig);
C->sig=aux;
c.frente=aux;
if(c.frente==NULL)
c.final=NULL;
}
}
letra Frente(){
return (c.frente->elem);
}
letra Final(){
return (c.final->elem);
}
void imprime(apt C){
posicion aux;
if (vacia(C))
printf("N/A");
else {
aux=C->sig;
while(aux!=NULL){
printf("%c ",aux->elem);
aux=aux->sig;
}
}
}
void Anula(apt C){
while(C->sig!=NULL)
suprimir(C);
}
#endif // COLA_H_INCLUDED
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.