diff options
Diffstat (limited to '2.3-1/src/c/statisticsFunctions/median/u16mediana.c')
-rw-r--r-- | 2.3-1/src/c/statisticsFunctions/median/u16mediana.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/2.3-1/src/c/statisticsFunctions/median/u16mediana.c b/2.3-1/src/c/statisticsFunctions/median/u16mediana.c index b45c5302..85cfedce 100644 --- a/2.3-1/src/c/statisticsFunctions/median/u16mediana.c +++ b/2.3-1/src/c/statisticsFunctions/median/u16mediana.c @@ -17,8 +17,10 @@ uint16 u16mediana(uint16 *in, int size) { - uint16 a; uint16 fin; + uint16 a; uint16 fin; uint16 in_copy[size]; +for(int i=0; i< size; i++) + in_copy[i]= in[i]; for (int i = 0; i < size; ++i) @@ -28,15 +30,15 @@ uint16 u16mediana(uint16 *in, int size) { - if (in[i] > in[j]) + if (in_copy[i] > in_copy[j]) { - a = in[i]; + a = in_copy[i]; - in[i] = in[j]; + in_copy[i] = in_copy[j]; - in[j] = a; + in_copy[j] = a; } @@ -46,11 +48,11 @@ uint16 u16mediana(uint16 *in, int size) if(size%2 ==0) { - fin= (in[size/2]+ in[(size/2)-1])/2; + fin= (in_copy[size/2]+ in_copy[(size/2)-1])/2; } else { - fin= in[(size-1)/2]; + fin= in_copy[(size-1)/2]; } return fin; |