clear
dime a(10)
for i=1 to 10
a(i)=int(rand()*100+1)
endfor
for i=1 to 10
??a(i)
endfor
c=findmax(@a)
?c
set talk on
cancel
function findmax (g)
k=0
max0=g(1)&&报错。找不到g.prg,明明是数组,咋报错程序文件呢?
for i=2 to 10
if max0<g(i)
max0=g(i)
k=i
endif
endfor
return k
endfunc
用传址的方式传递参数,可以避免错误发生dime a(10)
for i=1 to 10
a(i)=int(rand()*100+1)
endfor
for i=1 to 10
??a(i)
endfor
c=findmax(@a)
?c
set talk on
cancel
function findmax (g)
k=0
max0=g(1)&&报错。找不到g.prg,明明是数组,咋报错程序文件呢?
for i=2 to 10
if max0<g(i)
max0=g(i)
k=i
endif
endfor
return k
endfunc
注意:@的用法
坚守VFP最后的阵地