.H
Publicado por sesur (7 intervenciones) el 31/05/2004 01:34:34
Hola, quisiera saber como puedo meter unas funciones que tengo en una libreria,
especifico las funciones:
/*************************************COLAS*****************************/
//ESTRUCTURA DE LA COLA
struct cola{
int info;
struct cola *sig;
struct cola *ant;
};
//CREA EL NODO DE ENCABEZAMIENTO DE LA COLA
struct cola crear_cola()
{
struct cola *nuevo=new cola;
nuevo->sig=nuevo->ant=nuevo;
}
//REVISA SI ESTA VACIA LA COLA
int vacia_cola(struct cola *p)
{
return(p->sig==cola);
}
//DEVUELVE EL INFO DEL PRIMER NODO DE LA COLA
int getinfo_cola(struct cola *p)
{
if (!vacia_cola(p))
return(p->sig->info);
}
//BORRA EL PRIMER NODO DE LA COLA, DEVUELVE SU PARTE INFO
int atender(struct cola *p)
{
struct cola *q;
int x;
if (!vacia_cola(p))
{
q=p->sig;
p->sig=q->sig;
p->sig->ant=p;
x=q->info;
free(q);
retur(x);
}
}
//INSERTA UN NUEVO NODO EN LA COLA
void suma(struct cola *p, int x)
{
struct cola *nuevo=new cola;
nuevo->ant=p->ant;
nuevo->sig=p;
p->ant->sig=nuevo;
p->ant=nuevo;
nuevo->info=x;
}
gracias.
especifico las funciones:
/*************************************COLAS*****************************/
//ESTRUCTURA DE LA COLA
struct cola{
int info;
struct cola *sig;
struct cola *ant;
};
//CREA EL NODO DE ENCABEZAMIENTO DE LA COLA
struct cola crear_cola()
{
struct cola *nuevo=new cola;
nuevo->sig=nuevo->ant=nuevo;
}
//REVISA SI ESTA VACIA LA COLA
int vacia_cola(struct cola *p)
{
return(p->sig==cola);
}
//DEVUELVE EL INFO DEL PRIMER NODO DE LA COLA
int getinfo_cola(struct cola *p)
{
if (!vacia_cola(p))
return(p->sig->info);
}
//BORRA EL PRIMER NODO DE LA COLA, DEVUELVE SU PARTE INFO
int atender(struct cola *p)
{
struct cola *q;
int x;
if (!vacia_cola(p))
{
q=p->sig;
p->sig=q->sig;
p->sig->ant=p;
x=q->info;
free(q);
retur(x);
}
}
//INSERTA UN NUEVO NODO EN LA COLA
void suma(struct cola *p, int x)
{
struct cola *nuevo=new cola;
nuevo->ant=p->ant;
nuevo->sig=p;
p->ant->sig=nuevo;
p->ant=nuevo;
nuevo->info=x;
}
gracias.
Valora esta pregunta


0