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");
- int main()
- {
- prim=NULL;
- while(fin>>x)
- {
- p=new nod;
- p->info=x;
- s=s+x;
- p->urm=NULL;
- p->ant=NULL;
- if(prim==NULL)
- {
- prim=p;
- ultim=p;
- }
- else
- {
- ultim->urm=p;
- p->ant=ultim;
- ultim=p;
- }
- }
- p=ultim;
- while(p!=NULL)
- {
- cout<<p->info<<" ";
- p=p->ant;
- }
- q=new nod;
- q->info=s;
- q->urm=prim;
- q->ant=NULL;
- prim->and=q;
- prim=q;
- p=prim;
- while(p!=NULL)
- {
- cout<<p->info<<' ';
- p=p->urm;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement