File tree Expand file tree Collapse file tree 2 files changed +4
-5
lines changed Expand file tree Collapse file tree 2 files changed +4
-5
lines changed Original file line number Diff line number Diff line change 10
10
void selection_sort (int * array , size_t size )
11
11
{
12
12
size_t i , j , cur_min ;
13
- bool min_found ; /* tracks whether a lesser value is found */
13
+ int min_found ; /* tracks whether a lesser value is found */
14
14
15
15
/* there's no need to perform sorting on empty or one-element arrays */
16
- if (size == 0 || size == 1 )
16
+ if (array == NULL || size < 2 )
17
17
return ;
18
18
19
19
for (i = 0 ; i < size - 1 ; i ++ )
20
20
{
21
21
cur_min = i ;
22
- min_found = false ;
22
+ min_found = 0 ;
23
23
24
24
for (j = i + 1 ; j < size ; j ++ )
25
25
{
26
26
if (array [j ] < array [cur_min ])
27
27
{
28
28
cur_min = j ;
29
- min_found = true ;
29
+ min_found = 1 ;
30
30
}
31
31
}
32
32
Original file line number Diff line number Diff line change 3
3
4
4
#include <stdio.h>
5
5
#include <stdlib.h>
6
- #include <stdbool.h>
7
6
8
7
/**
9
8
* struct listint_s - Doubly linked list node
You can’t perform that action at this time.
0 commit comments