swift算法手记-8

swift算法手记-8,第1张

概述if answer==nil{ //计算方程的解 var p0:Double=leftbound! var p1:Double=rightbound! var q0:Double = comresult(p0) var q1:Double = comresult(p1)
if answer==nil{            //计算方程的解            var p0:Double=leftbound!            var p1:Double=rightbound!            var q0:Double = comresult(p0)            var q1:Double = comresult(p1)            var p:Double=0            var q:Double=0                        for i in 2...trycount{                                p = secantcompresult(p0,myp1:p1)                if abs(p-p1) < accuracy {                    answer=p0                    break                }                q = comresult(p)                if q * q1 < 0 {                    p0=p1                    q0=q1                }                p1=p                q1=q            }        }        if let ans=answer{            //方程有解            result.stringValue="解:"+String(stringInterpolationSegment: ans)+"   "            result.stringValue += "解代入方程的值:"+String(stringInterpolationSegment:comresult(ans))        }
@H_419_4@本博客所有内容是原创,如果转载请注明来源 http://blog.csdn.net/myhaspl/ 总结

以上是内存溢出为你收集整理的swift算法手记-8全部内容,希望文章能够帮你解决swift算法手记-8所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1080220.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存