Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 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 selectionSort(void)
  11. {
  12. for (int i = 0; i < v.size() - 1; i++)
  13. {
  14. int temp = v[i];
  15.  
  16. // 최솟값 탐색
  17. for (int j = i + 1; j < v.size(); j++)
  18. {
  19. if (v[j] < v[temp])
  20. {
  21. temp = j;
  22. }
  23. }
  24.  
  25. if (i != temp)
  26. {
  27. swap(v[i], v[temp]);
  28. }
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement