#include #include #include "List.h" Node * newNode( int dat ) { Node * p = malloc( sizeof( Node ) ); p->data = dat; p->next = NULL; return p; } void Listinit( List * L ) { L->first = NULL; } /* Inserção recursiva, metodo interno. */ Node * insert( int data, Node * node ) { if ( node == NULL ) return newNode( data ); node->next = insert( data, node->next ); return node; } /* Inserção. Usa o método auxiliar */ void Listinsert( List * L, int data ) { L->first = insert( data, L->first ); } /* Remoção do primeiro elemento */ int Listremove( List * L ) { if ( L->first == NULL ) return -1; Node * p = L->first; L->first = L->first->next; int res = p->data; free( p ); return res; } void Nodeprint( Node * node ) { if ( node == NULL ) return; printf( "%d ", node->data ); Nodeprint( node->next ); } void Listprint( List L ) { Nodeprint( L.first ); printf( "\n" ); }