Advertisement
a53

LsiInterclasare

a53
Jun 21st, 2021
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. void LsiInterclasare(Nod *h1, Nod *h2, Nod *&h)
  2. {
  3. Nod *orgh1=h1;
  4. Nod *orgh2=h2;
  5. Nod *h3=NULL;
  6. Nod *tail=NULL;
  7. while(orgh1!=NULL && orgh2!=NULL)
  8. {
  9. if(orgh1->info <= orgh2->info)
  10. {
  11. if(h3==NULL)
  12. h3=tail=orgh1;
  13. else
  14. {
  15. tail->leg=orgh1;
  16. tail=orgh1;
  17. }
  18. orgh1=orgh1->leg;
  19. }
  20. else
  21. {
  22. if(h3==NULL)
  23. h3=tail=orgh2;
  24. else
  25. {
  26. tail->leg=orgh2;
  27. tail=orgh2;
  28. }
  29. orgh2=orgh2->leg;
  30. }
  31. }
  32. if(orgh1==NULL)
  33. {
  34. if(h3==NULL)
  35. h3=orgh2;
  36. else
  37. tail->leg=orgh2;
  38. }
  39. else
  40. {
  41. if(h3==NULL)
  42. h3=orgh1;
  43. else
  44. tail->leg=orgh1;
  45. }
  46. h=h3;
  47. }
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement