Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. void sort(int a[],int first, int last){
  2. int pivot, i, j, tmp;
  3. if (first<last){
  4. pivot = first;
  5. i = first;
  6. j = last;
  7. while(i<j){
  8. while(a[i]<=a[pivot]&&i<last)
  9. i++;
  10. while(a[j]>a[pivot])
  11. j--;
  12. if(i<j){
  13. temp=a[i];
  14. a[i] = a[j];
  15. a[j] = temp;
  16. }
  17. }
  18. temp = a[pivot];
  19. a[pivot] = a[j];
  20. a[j] = temp;
  21. sort(a,first,j-1);
  22. sort(a,j+1,last);
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement