@xyVal = (4,4,6,6,10,12,18,22,24,28,30);
@yVal = (176,178,180,184,192,202,210,218,224,232,238);
@xxVal = (9,9,9,9,9 ,11,13,15,17,19,19);
@xVal = (168,166,164,162,158,150,142,134,122,116,110);
for ($i = 0; $i < scalar(@xVal); $i++){
for ($i = 0; @xyVal[$i] < @xxVal[$i]; $i++){
@yNewVal = @yVal[$i-1] + (@yVal[$i] - @yVal[$i-1])*(@xxVal[$i] - @xyVal[$i-1])/(@xyVal[$i] - @xyVal[$i-1]);
}
}
print @yNewVal;
我明白为什么它给了我Illegal division by zero
关于第 9 行的错误(@yNewVal = ...)
如果零之间存在除法,我希望数组中包含 0。我究竟做错了什么?那么,当除以零时,如何避免我的应用程序崩溃?