Advertisement
Guest User

asgagsaga

a guest
Jan 20th, 2020
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 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 *v,int nr,nod *&sf)
  7. {
  8. nod *c;
  9. if (v==0)
  10. {
  11. v=new nod;
  12. v->info=nr;
  13. v->ad=0;
  14. sf=v;
  15. }
  16. else
  17. {
  18. c=new nod;
  19. c->info=nr;
  20. c->ad=0;
  21. sf->ad=c;
  22. sf=c;
  23. }
  24. }
  25. void afisare (nod *v)
  26. {
  27. nod *c;
  28. while(c!=0)
  29. {
  30. cout<<c->info;
  31. c=c->ad;
  32. }
  33. }
  34. void main()
  35. {
  36. for(int i=1;i<=10;i++)
  37. adaugare (v,i,sf);
  38. afisare (v);
  39. getch();}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement