Facebook
From Torrid Flamingo, 6 Years ago, written in C++.
This paste is a reply to Re: Re: Untitled from Emerald Shama - view diff
Embed
Download Paste or View Raw
Hits: 331
  1. int partition(bank *tab, int begin, int end) {
  2.     int pivot = tab[end].suma_gotowki;
  3.     int i = (begin - 1);
  4.  
  5.     for (int j = begin; j < end; j++) {
  6.         if (tab[j].suma_gotowki <= pivot) {
  7.             i++;
  8.             swap(tab[i], tab[j]);
  9.         }
  10.     }
  11.     swap(tab[i + 1], tab[end]);
  12.     return i + 1;
  13. }
  14.  
  15. void quickSort(bank *tab, int begin, int end) {
  16.     if (begin < end) {
  17.         int partitionIndex = partition(tab, begin, end);
  18.  
  19.         quickSort(tab, begin, partitionIndex - 1);
  20.         quickSort(tab, partitionIndex + 1, end);
  21.     }
  22. }
  23.  

Replies to Re: Re: Re: Untitled rss

Title Name Language When
Re: Re: Re: Re: Untitled Wet Dolphin cpp 6 Years ago.
stos Chartreuse Frog cpp 6 Years ago.
captcha