diff --git a/core/logic/smn_sorting.cpp b/core/logic/smn_sorting.cpp index 59856cf0..65d0a5db 100644 --- a/core/logic/smn_sorting.cpp +++ b/core/logic/smn_sorting.cpp @@ -94,7 +94,7 @@ void sort_random(cell_t *array, cell_t size) for (int i = size-1; i > 0; i--) { - int n = (rand() % i) + 1; + int n = rand() % (i + 1); if (array[i] != array[n]) { @@ -435,7 +435,7 @@ void sort_adt_random(CellArray *cArray) for (int i = arraysize-1; i > 0; i--) { - int n = (rand() % i) + 1; + int n = rand() % (i + 1); cArray->swap(i, n); }