#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;
struct nod
{
    int inf;
    struct nod* leg;
};
struct nod* creare();
void parcurgere(struct nod*);
void parcurgere_inv(struct nod*);
void stergere(struct nod*);
int main()
{
    {struct nod* cap;
    cap=creare();
    cout<<"\nParcurgere cap-coada ";
    parcurgere(cap);
    cout<<"\nParcurgere inversa: ";
    parcurgere_inv(cap);
    stergere (cap);
    return 0;
    }
}
    struct nod *creare()
    {
        int inf;
        struct nod *p;
        cout<<"Informatia: ";
        cin>>inf;
        p= (struct nod*) malloc(sizeof(struct nod));
        p->inf=inf;
        fflush(stdin);
        cout<<"Continuati introducerea? (y/n) ";
        if (getchar()=='y') p->leg=creare();
        else p->leg=NULL;
        return(p);
    }
    void parcurgere(struct nod *p)
    {
        if(p!=NULL)
        {
            printf("%d ", p->inf);
            parcurgere(p->leg);
        }
    }
    void parcurgere_inv(struct nod *p)
    {
        if (p!=NULL)
        {
            parcurgere_inv(p->leg);
            printf("%d ", p->inf);
        }
    }
    void stergere(struct nod *p)
    {
        if (p!=NULL)
        {
            stergere(p->leg);
            free(p);
        }
    }