问题描述
我用 Octave 编写了这段代码。
x=0.0;
while (x~=1.0)
x=x+0.1;
fprintf('x=%20.18f\n',x)
pause
endwhile
我想在 x
等于 1
时停止代码。
所以,我放了一些这样的代码
x=0.0;
while (x~=1.0)
x=x+0.1;
fprintf('x=%20.18f\n',x)
if abs(x-1)<(eps/2),print(x)
endif
pause
endwhile
但它不起作用,并无限显示数字。当 x
等于 1
时,如何编写代码来停止此代码?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)