#include #include typedef struct DCVOR{ int br; struct DCVOR *sl; struct DCVOR *pr; }dCVOR; dCVOR *napravi(int br){ dCVOR *novi=(dCVOR*)malloc(sizeof(dCVOR)); if(novi==NULL) exit(EXIT_FAILURE); novi->br=br; novi->sl=NULL; novi->pr=NULL; return novi; } dCVOR *dodajp(dCVOR *pl,dCVOR **kl, int br){ if(pl==NULL){ pl=napravi(br); *kl=pl; return pl; }else{ dCVOR *novi=napravi(br); novi->sl=pl; pl->pr=novi; return novi; } } int main(){ dCVOR *pl; dCVOR *kl; dCVOR *pom; int i; pl=NULL; kl=NULL; for(i=0; i<10; i++) pl=dodajp(pl,&kl,i); pom=pl; while(pom!=NULL){ printf("%d\t",pom->br); pom=pom->sl; } printf("\n"); pom=kl; while(pom!=NULL){ printf("%d\t",pom->br); pom=pom->pr; } printf("\n"); return 0; }