SHARE
TWEET

Untitled

a guest Oct 23rd, 2019 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. using namespace std;
  5.  
  6. const int MAX = 1e6;
  7.  
  8. vector<int> v(MAX, 0);
  9.  
  10. void insertionSort(void)
  11. {
  12.     for (int i = 1; i < v.size(); i++)
  13.     {
  14.         // i 번째까지는 정렬되어있다고 가정
  15.         int temp = v[i];
  16.  
  17.         int j;
  18.  
  19.         for (j = i - 1; j >= 0 && v[j] > temp; j--)
  20.         {
  21.             v[j + 1] = v[j];
  22.         }
  23.  
  24.         v[j + 1] = temp;
  25.     }
  26. }
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