Skip to content
Snippets Groups Projects
Verified Commit 04ff3346 authored by orestis.malaspin's avatar orestis.malaspin
Browse files

added swap

parent 90e53aaa
Branches
No related tags found
No related merge requests found
Pipeline #14561 passed
......@@ -15,6 +15,12 @@ void find_min(double tab[], int i0, int *ind, double *min) {
}
}
void swap(double *a, double *b) {
double tmp = *a;
*a = *b;
*b = tmp;
}
int main() {
srand(time(NULL));
double tab[SIZE];
......@@ -26,9 +32,7 @@ int main() {
double min = tab[i];
int ind_min = i;
find_min(tab, i, &ind_min, &min);
double tmp = tab[i];
tab[i] = min;
tab[ind_min] = tmp;
swap(&tab[i], &tab[ind_min]);
}
for (int i = 0; i < SIZE; ++i) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment