Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void FLsiDesc(Nod *head)
- {
- Nod *p=head,*nou,*ultim=head;
- while(p!=NULL&&p->leg!=NULL)
- {
- while(p->info-p->leg->info>1) /// Cat timp diferenta e >1 adaug nodurile care lipsesc
- {
- nou=new Nod; /// Cream un nou nod
- nou->info=p->info-1;
- nou->leg=p->leg; /// Il legam de urmatorul nod
- p->leg=nou; /// Legam nodul anterior p de noul nod
- p=nou; /// Acum p va indica noul nod introdus
- }
- ultim=p,p=p->leg;
- if(p->leg==NULL)
- ultim=p,p=p->leg;
- }
- int n=ultim->info;
- while(--n)
- {
- nou=new Nod;
- nou->info=ultim->info-1;
- ultim->leg=nou;
- nou->leg=NULL;
- ultim=nou;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement