下载MetaTrader 5
要添加评论,请登录注册
如何使用MQL5.community的信息编辑器!在文章中找出答案!
justincn
24
justincn 2011.11.21 00:44 

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;

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

goodgame
31
goodgame 2011.11.24 09:05  
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;

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

看看C语言的书吧
/
要添加评论,请登录注册