如何计算数组中的最大最小值?或者如何将数组变成数?
mfp吧
全部回复
仅看楼主
level 12
喂wswswsws 楼主
2016年11月03日 13点11分 1
level 1
variable my_max = -10000000
for variable idx = 0 to size(myarray)[0] step 1
if (myarray[idx] > my_max)
my_max = myarray[idx]
endif
loop
2016年11月03日 22点11分 2
谢谢!本来我是想计算一个数组中的最大最小值的,后来在系统函数中找到了一个$>get_extreme_elem()。但你的办法也非常好,以后可以计算数组的平均数,排序,等等。
2016年11月03日 23点11分
size(myarray)[0]是什么意思啊?好像size()的用法不是这样用的。
2016年11月04日 01点11分
@喂wswswsws help size
2016年11月04日 02点11分
level 12
喂wswswsws 楼主
我想把数组打印成数,为什么第三行总是出错?为什么c=alloc_array()是错的?@woshiwppaa
citingspace tools
function array_num(c)
c=alloc_array()
return c
variable my_max = -10000000
for variable idx = 0 to size(c[]) step 1
if (c[idx] > my_max)
my_max = d[idx]
endif
loop
endf
2016年11月04日 01点11分 3
c = alloc_array(1,2) ---- OK c = alloc_array() ---- wrong help alloc_array
2016年11月04日 02点11分
level 13
[真棒]
2016年11月04日 08点11分 4
level 12
喂wswswsws 楼主
为什么if d[idx] > my_num是错的索引?@woshiwppaa
citingspace tools
function array_num(d)
variable my_num=-999999
for variable idx=0 to size(d) step 1
if d[idx] > my_num
print(d[idx])
endif
next
endf
2016年11月04日 12点11分 5
@zhengtao94364 大神帮忙看看为什么d[idx]是错误的?
2016年11月05日 09点11分
level 12
喂wswswsws 楼主
度娘在吗?
2016年11月05日 13点11分 9
level 12
喂wswswsws 楼主
度娘我的八楼呢?哼哼哼哼哼哼哼哼哼哼哼哼!
2016年11月05日 13点11分 10
1