Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. void sortowanie_przez_wstawianie_polowkowe(int *table, int size)
  2. {
  3.     int i;
  4.     for (i = 1; i < size; i++)
  5.     {
  6.         int j, start, p, currentValue, half;
  7.         currentValue = table[i];
  8.         start = 0;
  9.         p = i - 1;
  10.         while (start <= p)
  11.         {
  12.             half = (start + p) / 2;
  13.             if (currentValue < table[half])
  14.             {
  15.                 p = half - 1;
  16.             }
  17.             else
  18.             {
  19.                 start = half + 1;
  20.             }
  21.         }
  22.         for (j = i - 1; j >= start; --j)
  23.         {
  24.             table[j + 1] = table[j];
  25.         }
  26.         table[start] = currentValue;
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement