Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement