Compare commits

..

2 Commits

Author SHA1 Message Date
olli
4174b3f7e3 calc median g_ 2024-08-16 23:06:35 +02:00
olli
9d5f5eac9f calc median g_ 2024-08-16 22:51:45 +02:00

View File

@ -14,11 +14,14 @@ function g_median {
local g_middle=$((g_num_elements/2))
local g_median
# Falls die Anzahl der Elemente ungerade ist
if ((g_num_elements % 2 == 1)); then
# even/odd number
if ((g_num_elements % 2 == 1))
then
# odd number
echo "g_middle=$g_middle"
g_median=${g_sorted_numbers[g_middle]}
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_median=$g_calc_result
fi