Guest User

Untitled

a guest
May 22nd, 2019
82
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. struct Nod
  6. {
  7. int info;
  8. Nod *st, *dr;
  9. };
  10. Nod *L, *U;
  11.  
  12. void Creare (int x)
  13. {
  14. L = new Nod;
  15. U = L;
  16. L -> st = L -> dr = NULL;
  17. l -> info = x;
  18. }
  19.  
  20. void InsInainte (Nod *p, int x)
  21. {
  22. Nod *q = new Nod;
  23. q -> info = x;
  24. q -> dr = p;
  25. q -> st = p -> st;
  26. p -> st -> dr = q;
  27. p -> st = q;
  28. }
  29.  
  30. void InsInceput (int x)
  31. {
  32. Nod *p = new Nod;
  33. p -> info = x;
  34. p -> dr = L;
  35. p -> st = NULL;
  36. L -> st = p;
  37. L = p;
  38. }
  39.  
  40. void ParcSD ()
  41. {
  42. for (Nod *p = L; p != NULL; p = p -> dr)
  43. cout << p -> info << " ";
  44. cout << "\n";
  45. }
  46.  
  47. int main()
  48. {
  49. int n;
  50. cin >> n;
  51. cin >> x;
  52. Creare(x);
  53. for (i = 2; i <= n; i++)
  54. InsInainte()
  55.  
  56. return 0;
  57. }
RAW Paste Data