Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. #include<fstream>
  2. using namespace std;
  3. ifstream fin ("prog.in");
  4. ofstream fout ("prog.out");
  5. struct nod
  6. {
  7. int a;
  8. nod * u;
  9. };
  10. nod * v=new nod;
  11. nod * pp;
  12. void creare(nod *prim)
  13. {
  14. int nr;
  15. fin>>nr;
  16. prim=new nod;
  17. pp=prim;
  18. prim->a=nr;
  19. while(fin>>nr)
  20. {
  21. nod * p=new nod;
  22. p->a=nr;
  23. prim->u=p;
  24. prim=p;
  25. }
  26. prim->u=NULL;
  27. }
  28. void afisare(nod * p)
  29. {
  30. while(p!=NULL)
  31. {
  32. fout<<p->a<<' ';
  33. p=p->u;
  34. }
  35. }
  36. int main()
  37. {
  38. creare(v);
  39. afisare(pp);
  40. return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement