Compare commits
2 Commits
4f2f11bd1a
...
4174b3f7e3
Author | SHA1 | Date | |
---|---|---|---|
|
4174b3f7e3 | ||
|
9d5f5eac9f |
@ -14,11 +14,14 @@ function g_median {
|
|||||||
local g_middle=$((g_num_elements/2))
|
local g_middle=$((g_num_elements/2))
|
||||||
|
|
||||||
local g_median
|
local g_median
|
||||||
# Falls die Anzahl der Elemente ungerade ist
|
# even/odd number
|
||||||
if ((g_num_elements % 2 == 1)); then
|
if ((g_num_elements % 2 == 1))
|
||||||
|
then
|
||||||
|
# odd number
|
||||||
|
echo "g_middle=$g_middle"
|
||||||
g_median=${g_sorted_numbers[g_middle]}
|
g_median=${g_sorted_numbers[g_middle]}
|
||||||
else
|
else
|
||||||
# Falls die Anzahl der Elemente gerade ist
|
# even number
|
||||||
g_calc "(${g_sorted_numbers[g_middle - 1]} + ${g_sorted_numbers[g_middle]}) / 2"
|
g_calc "(${g_sorted_numbers[g_middle - 1]} + ${g_sorted_numbers[g_middle]}) / 2"
|
||||||
g_median=$g_calc_result
|
g_median=$g_calc_result
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user