Advertisement
Guest User

Untitled

a guest
Apr 24th, 2018
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4. ifstream f("atestat.in");
  5. int main()
  6. {
  7. prim=NULL;
  8. while(fin>>x)
  9. {
  10. p=new nod;
  11. p->info=x;
  12. s=s+x;
  13. p->urm=NULL;
  14. p->ant=NULL;
  15. if(prim==NULL)
  16. {
  17. prim=p;
  18. ultim=p;
  19. }
  20. else
  21. {
  22. ultim->urm=p;
  23. p->ant=ultim;
  24. ultim=p;
  25. }
  26. }
  27. p=ultim;
  28. while(p!=NULL)
  29. {
  30. cout<<p->info<<" ";
  31. p=p->ant;
  32. }
  33. q=new nod;
  34. q->info=s;
  35. q->urm=prim;
  36. q->ant=NULL;
  37. prim->and=q;
  38. prim=q;
  39. p=prim;
  40. while(p!=NULL)
  41. {
  42. cout<<p->info<<' ';
  43. p=p->urm;
  44. }
  45. return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement