Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //NETESTATE, UNELE NU MERG
- #include <iostream>
- #include <fstream>
- using namespace std;
- ifstream f("date.in");
- struct nod
- {
- int info;
- nod *st,*dr;
- };
- nod *prim,*ultim;
- void creare()
- {
- nod *nou;
- int x;
- while (f>>x)
- if (prim==NULL)
- {
- prim=new nod;
- prim->info=x;
- prim->st=NULL;
- ultim=prim;
- }
- else
- {
- nou=new nod;
- nou->info=x;
- nou->st=ultim;
- ultim->dr=nou;
- ultim=nou;
- }
- ultim->dr=NULL;
- }
- void parcurgere_st()
- {
- nod *p=ultim;
- while (p)
- {
- if (p->info%2==0)
- cout<<p->info<<" ";
- p=p->st;
- }
- }
- void parcurgere_dr()
- {
- nod *p=prim;
- while (p)
- {
- if (p->info%2==1)
- cout<<p->info<<" ";
- p=p->dr;
- }
- }
- void inserare()
- {
- nod *p=prim,nou;
- while (p->info%2!=0&&p)
- p=p->dr;
- if (p)
- {
- nou=new nod;
- nou->info=p->info*p->info;
- nou->dr=p->dr;
- nou->st=p;
- p->dr->st=nou;
- p->dr=nou;
- }
- }
- void stergere()//stergeti ultimul nod cu inf. para
- {
- nod *p=ultim,*q,*r;
- while (p->info%2==1 && p )
- p=p->st;
- q=p->dr;
- r=p->st;
- r->dr=q;
- q->st=r;
- delete p;
- }
- int main()
- {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement