Created
March 1, 2016 12:16
-
-
Save mkmkme/5baad7055b3887faa561 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 selection_sort(double *arr, size_t s) | |
{ | |
for (size_t i = 0; i < s; s++) | |
{ | |
size_t m_idx = i; | |
for (size_t j = i + 1; j < s; j++) | |
{ | |
if (arr[j] < arr[m_idx]) | |
m_idx = j; | |
} | |
if (m_idx != i) | |
{ | |
double t = arr[i]; | |
arr[i] = arr[m_idx]; | |
arr[m_idx] = t; | |
} | |
} | |
} | |
int main(void) | |
{ | |
double arr[64]; | |
selection_sort(arr, sizeof(arr) / sizeof(double)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment