#include #include struct Lista { int val; struct Lista *next; }; struct Lista *creaNodo(int val); struct Lista *popolaLista(struct Lista *testa, int i); void stampaLista(struct Lista *testa); int main(void) { struct Lista *lista = NULL; lista = popolaLista(lista, 5); stampaLista(lista); return 0; } struct Lista *creaNodo(int val) { struct Lista *nodo = (struct Lista *) malloc(sizeof(struct Lista)); nodo->val = val; nodo->next = NULL; return nodo; } struct Lista *popolaLista(struct Lista *testa, int i) { testa = NULL; if (i > 0) { testa = creaNodo(i); testa->next = popolaLista(testa->next, --i); } return testa; } void stampaLista(struct Lista *testa) { if (testa != NULL) { printf("Valore: %d;\n", testa->val); stampaLista(testa->next); } return; }