Advertisement
Guest User

Untitled

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