Sanady

Untitled

Oct 8th, 2019
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.25 KB | None | 0 0
  1. void insertionSort1(int* data, const size_t length) {
  2.     int i, key, j;
  3.     for (i = length-1; i >= 0; i--)
  4.     {
  5.         key = data[i];
  6.         j = i - 1;
  7.  
  8.         while (j >= 0 && data[j] > key)
  9.         {
  10.             data[j - 1] = data[j];
  11.             j = j - 1;
  12.         }
  13.         data[j - 1] = key;
  14.     }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment