SHARE
TWEET

let it gooo, let it goooo

a guest Dec 12th, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void MixedBubbleSort( int* tab, int nSize ) {
  2.     int start = 1; // Lewy indeks
  3.     int end = nSize - 1; // Prawy indeks
  4.     int k = end;
  5.     do {
  6.         for ( int j = end; j >= start; j-- ) {
  7.             if ( tab[j - 1] > tab[j] ) {
  8.                 int temp = tab[j - 1];
  9.                 tab[j - 1] = tab[j];
  10.                 tab[j] = temp;
  11.                 k = j;
  12.             }
  13.         }
  14.         // Element na indeksie start jest już na swoim miejscu
  15.         start = k + 1;
  16.         for ( int j = start; j <= end; j++ ) {
  17.             if ( tab[j - 1] > tab[j] ) {
  18.                 int temp = tab[j - 1];
  19.                 tab[j - 1] = tab[j];
  20.                 tab[j] = temp;
  21.                 k = j;
  22.             }
  23.         }
  24.         // Element na indeksie end jest już na swoim miejscu
  25.         end = k - 1;
  26.     } while ( start < end );
  27. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top