Advertisement
a53

FLsiDesc

a53
May 25th, 2022
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. void FLsiDesc(Nod *head)
  2. {
  3. Nod *p=head,*nou,*ultim=head;
  4. while(p!=NULL&&p->leg!=NULL)
  5. {
  6. while(p->info-p->leg->info>1) /// Cat timp diferenta e >1 adaug nodurile care lipsesc
  7. {
  8. nou=new Nod; /// Cream un nou nod
  9. nou->info=p->info-1;
  10. nou->leg=p->leg; /// Il legam de urmatorul nod
  11. p->leg=nou; /// Legam nodul anterior p de noul nod
  12. p=nou; /// Acum p va indica noul nod introdus
  13. }
  14. ultim=p,p=p->leg;
  15. if(p->leg==NULL)
  16. ultim=p,p=p->leg;
  17. }
  18. int n=ultim->info;
  19. while(--n)
  20. {
  21. nou=new Nod;
  22. nou->info=ultim->info-1;
  23. ultim->leg=nou;
  24. nou->leg=NULL;
  25. ultim=nou;
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement