From 764a04a201ed584d303a9dc514a5e9caff9fe47e Mon Sep 17 00:00:00 2001 From: Peace-Maker Date: Wed, 23 Jan 2013 12:51:19 -0500 Subject: [PATCH] Fixed Sort_Random not including first value in array sorting functions (bug 4292, r=psychonic). --- core/logic/smn_sorting.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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); }