Advertisement
Stancu

Tema

Oct 9th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6.  
  7. struct nod{
  8. int info;
  9. nod *leg;
  10. };
  11.  
  12.  
  13. nod *creare (){
  14. nod *prim, *p, *q;
  15. ifstream f ("date.in");
  16. prim = new nod;
  17. f>>prim->info;
  18. q=prim;
  19. while (f.good()){
  20. p = new nod;
  21. f>>p->info;
  22. q->leg=p;
  23. q=p;
  24. }
  25. p->leg=NULL;
  26. return prim;
  27. }
  28.  
  29. void afisare (nod *prim){
  30. nod *p = new nod;
  31. p=prim;
  32. while (p){
  33. cout<<p->info<<endl;
  34. p=p->leg;
  35. }
  36. }
  37.  
  38. int main()
  39. {
  40. afisare(creare());
  41. return 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement