Advertisement
Guest User

Insertion вставка

a guest
Oct 16th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.38 KB | None | 0 0
  1. void InsertionSort(int n, int mass[])
  2. {
  3.     int newElement, location;
  4.  
  5.     for (int i = 1; i < n; i++)
  6.     {
  7.         newElement = mass[i];
  8.         location = i - 1;
  9.         while(location >= 0 && mass[location] > newElement)
  10.         {
  11.             mass[location+1] = mass[location];
  12.             location = location - 1;
  13.         }
  14.         mass[location+1] = newElement;
  15.     }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement