calc median g_
This commit is contained in:
parent
4f2f11bd1a
commit
9d5f5eac9f
@ -13,15 +13,14 @@ function g_median {
|
||||
# calculate the middle
|
||||
local g_middle=$((g_num_elements/2))
|
||||
|
||||
local g_median
|
||||
# Falls die Anzahl der Elemente ungerade ist
|
||||
if ((g_num_elements % 2 == 1)); then
|
||||
g_median=${g_sorted_numbers[g_middle]}
|
||||
else
|
||||
# Falls die Anzahl der Elemente gerade ist
|
||||
g_calc "(${g_sorted_numbers[g_middle - 1]} + ${g_sorted_numbers[g_middle]}) / 2"
|
||||
g_median=$g_calc_result
|
||||
fi
|
||||
# local g_median
|
||||
# if ((g_num_elements % 2 == 1))
|
||||
# then
|
||||
# g_median=${g_sorted_numbers[g_middle]}
|
||||
# else
|
||||
# g_calc "(${g_sorted_numbers[g_middle - 1]} + ${g_sorted_numbers[g_middle]}) / 2"
|
||||
# g_median=$g_calc_result
|
||||
# fi
|
||||
|
||||
g_median_result=$g_median
|
||||
g_median_result=${g_sorted_numbers[g_middle]}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user