Advertisement
Guest User

Untitled

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