diff options
Diffstat (limited to 'src/c/statisticsFunctions/median/smediana.c')
-rw-r--r-- | src/c/statisticsFunctions/median/smediana.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/c/statisticsFunctions/median/smediana.c b/src/c/statisticsFunctions/median/smediana.c index 9e86b77..0d427e1 100644 --- a/src/c/statisticsFunctions/median/smediana.c +++ b/src/c/statisticsFunctions/median/smediana.c @@ -17,8 +17,10 @@ float smediana(float *in, int size) { - float a; float fin; + float a; float fin; float 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 @@ float smediana(float *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 @@ float smediana(float *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; |