Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- ifstream f("atestat.in");
- float x,sum;
- int nr;
- struct nod{
- float info;
- nod *urm;
- }*p,*varf;
- void creare()
- {
- while(f>>x)
- {
- sum+=x;
- nr++;
- p=new nod;
- p->info=x;
- if(varf==NULL)
- {p->urm=NULL; varf=p;}
- else
- {
- p->urm=varf;
- varf=p;
- }
- }
- }
- void tipar()
- {
- p=varf;
- while(p!=NULL)
- {
- cout<<p->info<<" ";
- p=p->urm;
- }
- }
- int main()
- {
- varf=NULL;
- creare();
- tipar();
- p=new nod;
- p->urm=varf;
- p->info=sum/nr;
- varf=p;
- cout<<"\n";
- tipar();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement