Advertisement
Guest User

giani

a guest
Jan 20th, 2020
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. #include <iostream.h>
  2. #include <conio.h>
  3. struct nod{int info ;nod *ad;}
  4. nod *v,*sf;
  5. int nr;
  6. void adaugare(nod *dv,int nr,nod *&sf)
  7. {if (v==0)
  8. {v=new nod;
  9. v->info=nr;
  10. v->ad=0;
  11. sf=v;}
  12. else
  13. {c=new nod;
  14. c->info=nr;
  15. c->ad=0;
  16. sf->ad=c;
  17. sf=c;}}
  18. void afisare(nod *v)
  19. {nod *c;
  20. c=v;
  21. while(c!=0)
  22. {cout<<c->info<<" ";
  23. c=c->ad;}}
  24. void main ()
  25. {for(int=1;i<10;i++)
  26. adaugare(v,i,sf);
  27. afisare(v);
  28. getch ();}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement