#include #include #define Vacia() (Base == NULL)?TRUE:FALSE typedef enum {FALSE=0,TRUE=1} boolean; typedef int TipoDato; struct SEle{ TipoDato valor; struct SEle *sig; struct SEle *ant; }; typedef struct SEle Elemento; Elemento *Base = NULL; boolean InsertarEnAnilloDoble ( TipoDato Dato) { Elemento *paux,*pa; paux = (Elemento *) malloc( sizeof(Elemento) ); if ( paux == NULL) { return FALSE; } paux->valor = Dato; if ( Base == NULL ) { Base = paux; paux->sig = Base; paux->ant = Base; } else { paux->sig = Base->sig; paux->ant = Base; pa = Base->sig; pa->ant = paux; Base->sig = paux; } return TRUE; } void VerAnilloS ( ) { Elemento *paux; printf("\n ANILLO S"); if ( !Vacia() ) { paux = Base; do { printf("->%d ",paux->valor); paux = paux->sig; } while ( paux != Base ); } } void VerAnilloA ( ) { Elemento *paux; printf("\n ANILLO A"); if ( !Vacia() ) { paux = Base; do { printf("->%d ",paux->valor); paux = paux->ant; } while ( paux != Base ); } } main() { InsertarEnAnilloDoble(10); InsertarEnAnilloDoble(11); InsertarEnAnilloDoble(12); InsertarEnAnilloDoble(13); VerAnilloS(); VerAnilloA(); getch(); }