﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-CoolWalf</title><link>http://www.cppblog.com/CoolWalf/</link><description /><language>zh-cn</language><lastBuildDate>Tue, 09 Jun 2026 23:57:52 GMT</lastBuildDate><pubDate>Tue, 09 Jun 2026 23:57:52 GMT</pubDate><ttl>60</ttl><item><title>c++实现变步长积分</title><link>http://www.cppblog.com/CoolWalf/archive/2008/10/19/64398.html</link><dc:creator>CoolWalf</dc:creator><author>CoolWalf</author><pubDate>Sun, 19 Oct 2008 03:42:00 GMT</pubDate><guid>http://www.cppblog.com/CoolWalf/archive/2008/10/19/64398.html</guid><wfw:comment>http://www.cppblog.com/CoolWalf/comments/64398.html</wfw:comment><comments>http://www.cppblog.com/CoolWalf/archive/2008/10/19/64398.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/CoolWalf/comments/commentRss/64398.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/CoolWalf/services/trackbacks/64398.html</trackback:ping><description><![CDATA[#include&lt;iostream.h&gt;<br>#include&lt;math.h&gt;<br>double f(double x)<br>{<br>&nbsp;if(x==0)<br>&nbsp;&nbsp;return 1;<br>&nbsp;else<br>&nbsp;return sin(x)/x;<br>}<br>double ff(double a,double b,double c)<br>{<br>&nbsp;double h=b-a;<br>&nbsp;double t1,t2=0,x,s=0;<br>&nbsp;t1=(h/2)*(f(a)+f(b));<br>&nbsp;while(fabs(t2-t1)&gt;c)<br>&nbsp;{<br>&nbsp;&nbsp;s=0;x=a+h/2;<br>&nbsp;&nbsp;t1=t2;<br>&nbsp;&nbsp;while(x&lt;b)<br>&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;s+=f(x);x+=h;<br>&nbsp;&nbsp;}<br>&nbsp;&nbsp;t2=t1/2+(h/2)*s;<br>&nbsp;&nbsp;h=h/2;<br>&nbsp;}<br>&nbsp;&nbsp;&nbsp; return t2;&nbsp;<br>}<br>void main()<br>{<br>&nbsp;double a,b,c;<br>&nbsp;cout&lt;&lt;"请分别输入上下限"&lt;&lt;endl;<br>&nbsp;cin&gt;&gt;a&gt;&gt;b;<br>&nbsp;cout&lt;&lt;"请输入误差限度："&lt;&lt;endl;<br>&nbsp;&nbsp;cin&gt;&gt;c;<br>&nbsp;&nbsp;cout&lt;&lt;ff(a,b,c)&lt;&lt;endl;<br>}
<img src ="http://www.cppblog.com/CoolWalf/aggbug/64398.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/CoolWalf/" target="_blank">CoolWalf</a> 2008-10-19 11:42 <a href="http://www.cppblog.com/CoolWalf/archive/2008/10/19/64398.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>