Last active
September 11, 2018 19:20
-
-
Save completejavascript/3ec23a5aaea325035f46051a6cc66721 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void SelectionSort(int *a, int N) | |
{ | |
for(int i = 0; i < N - 1; i++) | |
{ | |
int idmin = i; | |
// Tìm ra phần tử có giá trị nhỏ nhất | |
for(int j = i + 1; j < N; j++) | |
if(a[j] < a[idmin]) | |
idmin = j; | |
// Đổi chỗ phần tử đầu tiên của dãy còn lại với phần tử nhỏ nhất | |
swap(a[i], a[idmin]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment