# 有人可以帮忙这个代码吗？

24

HI,我只想求中位数，可是MEDIAN求出来的是0，貌似数组没有被赋值，能不能请高手帮忙改正一下，万分感谢。

//========================================================================

double median,array1[];

avr1 = 11.45;

avr2 = 4.6;

avr3 = 7.781254;

avr4 = 10.68211;

avr5 = 12.21;

avr6 = 11;

avr7 = 8;

avr8 = 20;

//only 8 numbers in this array.

array1[0] = avr1; array1[1] = avr2; array1[2] = avr3; array1[3] = avr4; array1[4] = avr5; array1[5] = avr6; array1[6] = avr7; array1[7] = avr8;

ArraySort(array1,WHOLE_ARRAY,0,MODE_DESCEND);

median=(array1[8/2]+array1[(8/2)-1])/2.0;

//================================================================================

30

justincn:

HI,我只想求中位数，可是MEDIAN求出来的是0，貌似数组没有被赋值，能不能请高手帮忙改正一下，万分感谢。

//========================================================================

double median,array1[];

avr1 = 11.45;

avr2 = 4.6;

avr3 = 7.781254;

avr4 = 10.68211;

avr5 = 12.21;

avr6 = 11;

avr7 = 8;

avr8 = 20;

//only 8 numbers in this array.

array1[0] = avr1; array1[1] = avr2; array1[2] = avr3; array1[3] = avr4; array1[4] = avr5; array1[5] = avr6; array1[6] = avr7; array1[7] = avr8;

ArraySort(array1,WHOLE_ARRAY,0,MODE_DESCEND);

median=(array1[8/2]+array1[(8/2)-1])/2.0;

//================================================================================