Guest User

Untitled

a guest
Jun 21st, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. void qSort(int vector[],int st,int dr)
  2. {
  3. int temp,min,max,mijl;
  4.  
  5. mijl = vector[st+(dr-st)/2]; //luam mijlocul intervalului
  6. min = st; max = dr;
  7. do
  8. {
  9. while(vector[min] < mijl) min++; //crescator
  10. while(vector[max] > mijl) max--; //crescator
  11. if(min <= max) //interschimbare
  12. {
  13. temp = vector[min];
  14. vector[min++] = vector[max];
  15. vector[max--] = temp;
  16. }
  17. }while(min <= max); //la fiecare pas sortam "mai bine" intervalul st-dr
  18.  
  19. //cand numai avem ce face schimbam intervalul
  20. if(st < max) qSort(vector,st,max); //crescator
  21. if(dr > min) qSort(vector,min,dr); //crescator
  22. }
Add Comment
Please, Sign In to add comment