Advertisement
Guest User

Untitled

a guest
Jan 20th, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include <iostream>
  2. #include<fstream>
  3.  
  4. using namespace std;
  5. struct NOD
  6. {
  7. int inf;
  8. NOD *urm,*ant;
  9. };
  10. void creare(int x)
  11. {
  12. prim=new NOD;
  13. prim->urm=prim->ant=NULL;
  14. ultim=prim;
  15. }
  16. void adaugare(int x)
  17. {
  18. NOD *nou;
  19. nou=new NOD;
  20. nou->inf=x;
  21. nou->urm=NULL;
  22. ultim->urm=nou;
  23. nou->ant=ultim;
  24. ultim=nou;
  25. }
  26. void adaugaref(int x)
  27. {
  28. NOD *nou;
  29. nou=new NOD;
  30. nou->inf=x;
  31. nou->ant=NULL;
  32. nou->urm=prim;
  33. prim->ant=nou;
  34. prim=nou;
  35. }
  36. void afisare2()
  37. {
  38. NOD *p;
  39. p=ultim;
  40. while(p!=NULL)
  41. {
  42. cout<<p->inf<<" ";
  43. p=p->ant;
  44. }
  45. }
  46.  
  47. int main()
  48. {
  49. ifstream in("lista.in");
  50. int x;
  51. in>>x;
  52. creare(x);
  53.  
  54. return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement