Advertisement
Guest User

Untitled

a guest
Apr 27th, 2015
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. inline void up(pole **kopc, int i){
  2. int k = i;
  3. int j = -3;
  4. while(k!=j){
  5. j=k;
  6. if((j-1)/2 >=0 && kopc[(j-1)/2]->koszt > kopc[k]->koszt)
  7. k = (j-1)/2;
  8. if(k!=j){
  9. int tmp1 = kopc[k]->poz;
  10. kopc[k]->poz = kopc[j]->poz;
  11. kopc[j]->poz = tmp1;
  12. pole *tmp = kopc[k];
  13. kopc[k] = kopc[j];
  14. kopc[j] = tmp;
  15. }
  16. }
  17. }
  18. inline void down(pole **kopc, int n){
  19. int k = 0;
  20. int j = -3;
  21. while(k!=j){
  22. j=k;
  23. if(2*j+1 < n && kopc[2*j+1]->koszt < kopc[k]->koszt)
  24. k = 2*j+1;
  25. if(2*j+2 < n && kopc[2*j+2]->koszt < kopc[k]->koszt)
  26. k = 2*j+2;
  27. if(k!=j){
  28. int tmp1 = kopc[k]->poz;
  29. kopc[k]->poz = kopc[j]->poz;
  30. kopc[j]->poz = tmp1;
  31. pole *tmp = kopc[k];
  32. kopc[k] = kopc[j];
  33. kopc[j] = tmp;
  34. }
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement