08/10/26 19:34:59
#676の続きです
def Vlookup(vs,v)
vx=vs.to_f
if (vx<v[0][0]) then
return -99.9
break
elsif (vx>v[v.size-1][0]) then
return 99.9
break
end
for i in 0..(v.size-1)
vpre=v[i][0]
vpst=v[i+1][0]
if (vx>vpre)&&(vx<=vpst) then
if (vpre-vx).abs<=(vpst-vx).abs then
num=i
elsif (vpre-vx).abs>(vpst-vx).abs then
num=i+1
end
break
end
end
return v[num][1]
end