Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. struct nod{
  6. int info;
  7. nod *urm;
  8. };
  9.  
  10. void ad_inc(nod *& p, int nr);
  11. void afisare (nod *p);
  12.  
  13. int main()
  14. {
  15. nod *prim = NULL;
  16. int n, nr;
  17. cin >> n;
  18. for (int i = 1; i <= n; i++)
  19. {
  20. cin >> nr;
  21. ad_inc(prim, nr);
  22. }
  23. afisare(prim);
  24. return 0;
  25. }
  26. void ad_inc(nod *& p, int nr)
  27. {
  28. if (!p) //lista e vida
  29. {
  30. p = new nod;
  31. p -> info = x;
  32. p -> urm = NULL;
  33. }
  34. else
  35. {
  36. nod *nou = new nod;
  37. nou -> info = x;
  38. nou -> urm = p;
  39. p = nou;
  40. }
  41. }
  42. void afisare (nod *p);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement