mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-03-22 12:52:48 +08:00
Documentation for c26eea874d
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
|
||||
<meta name="generator" content="Doxygen 1.12.0"/>
|
||||
<meta name="generator" content="Doxygen 1.13.2"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<title>TheAlgorithms/C++: math/approximate_pi.cpp Source File</title>
|
||||
<link rel="icon" href="../../favicon.svg" type="image/x-icon" />
|
||||
@@ -60,7 +60,7 @@ window.MathJax = {
|
||||
</table>
|
||||
</div>
|
||||
<!-- end header part -->
|
||||
<!-- Generated by Doxygen 1.12.0 -->
|
||||
<!-- Generated by Doxygen 1.13.2 -->
|
||||
<script type="text/javascript">
|
||||
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||||
var searchBox = new SearchBox("searchBox", "../../search/",'.html');
|
||||
@@ -124,25 +124,26 @@ $(function(){initNavTree('d0/d51/approximate__pi_8cpp_source.html','../../'); in
|
||||
<div class="headertitle"><div class="title">approximate_pi.cpp</div></div>
|
||||
</div><!--header-->
|
||||
<div class="contents">
|
||||
<a href="../../d0/d51/approximate__pi_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno"> 1</span> </div>
|
||||
<a href="../../d0/d51/approximate__pi_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno"> 1</span></div>
|
||||
<div class="line"><a id="l00019" name="l00019"></a><span class="lineno"> 19</span> </div>
|
||||
<div class="line"><a id="l00020" name="l00020"></a><span class="lineno"> 20</span><span class="preprocessor">#include <cassert></span> </div>
|
||||
<div class="line"><a id="l00021" name="l00021"></a><span class="lineno"> 21</span><span class="preprocessor">#include <cstdlib></span> </div>
|
||||
<div class="line"><a id="l00022" name="l00022"></a><span class="lineno"> 22</span><span class="preprocessor">#include <iostream></span> </div>
|
||||
<div class="line"><a id="l00023" name="l00023"></a><span class="lineno"> 23</span><span class="preprocessor">#include <vector></span> </div>
|
||||
<div class="line"><a id="l00024" name="l00024"></a><span class="lineno"> 24</span> </div>
|
||||
<div class="line"><a id="l00024" name="l00024"></a><span class="lineno"> 24</span></div>
|
||||
<div class="line"><a id="l00029" name="l00029"></a><span class="lineno"> 29</span><span class="keyword">namespace </span><a class="code hl_namespace" href="../../dd/d47/namespacemath.html">math</a> {</div>
|
||||
<div class="line"><a id="l00030" name="l00030"></a><span class="lineno"> 30</span> </div>
|
||||
<div class="line"><a id="l00030" name="l00030"></a><span class="lineno"> 30</span></div>
|
||||
<div class="foldopen" id="foldopen00035" data-start="{" data-end="};">
|
||||
<div class="line"><a id="l00035" name="l00035"></a><span class="lineno"><a class="line" href="../../dd/d47/namespacemath.html#a006c8ebd11bb1e035815dc835a1a7a85"> 35</a></span><span class="keyword">using </span><a class="code hl_struct" href="../../d8/dc8/struct_point.html">Point</a> = <span class="keyword">struct </span>{</div>
|
||||
<div class="line"><a id="l00035" name="l00035"></a><span class="lineno"><a class="line" href="../../dd/d47/namespacemath.html#a006c8ebd11bb1e035815dc835a1a7a85"> 35</a></span><span class="keyword">using </span><a class="code hl_typedef" href="../../dd/d47/namespacemath.html#a006c8ebd11bb1e035815dc835a1a7a85">Point</a> = <span class="keyword">struct </span>{</div>
|
||||
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno"> 36</span> <span class="keywordtype">double</span> x;</div>
|
||||
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno"> 37</span> <span class="keywordtype">double</span> y;</div>
|
||||
<div class="line"><a id="l00038" name="l00038"></a><span class="lineno"> 38</span>};</div>
|
||||
</div>
|
||||
<div class="line"><a id="l00039" name="l00039"></a><span class="lineno"> 39</span> </div>
|
||||
<div class="line"><a id="l00039" name="l00039"></a><span class="lineno"> 39</span></div>
|
||||
<div class="foldopen" id="foldopen00047" data-start="{" data-end="}">
|
||||
<div class="line"><a id="l00047" name="l00047"></a><span class="lineno"><a class="line" href="../../dd/d47/namespacemath.html#abf7f2a6d91f1ca6c89698792aea3f188"> 47</a></span><span class="keywordtype">double</span> <a class="code hl_function" href="../../dd/d47/namespacemath.html#abf7f2a6d91f1ca6c89698792aea3f188">approximate_pi</a>(<span class="keyword">const</span> std::vector<Point> &pts) {</div>
|
||||
<div class="line"><a id="l00048" name="l00048"></a><span class="lineno"> 48</span> <span class="keywordtype">double</span> count = 0; <span class="comment">// Points in circle</span></div>
|
||||
<div class="line"><a id="l00049" name="l00049"></a><span class="lineno"> 49</span> <span class="keywordflow">for</span> (<a class="code hl_struct" href="../../d8/dc8/struct_point.html">Point</a> p : pts) {</div>
|
||||
<div class="line"><a id="l00049" name="l00049"></a><span class="lineno"> 49</span> <span class="keywordflow">for</span> (<a class="code hl_typedef" href="../../dd/d47/namespacemath.html#a006c8ebd11bb1e035815dc835a1a7a85">Point</a> p : pts) {</div>
|
||||
<div class="line"><a id="l00050" name="l00050"></a><span class="lineno"> 50</span> <span class="keywordflow">if</span> ((p.x * p.x) + (p.y * p.y) <= 1) {</div>
|
||||
<div class="line"><a id="l00051" name="l00051"></a><span class="lineno"> 51</span> count++;</div>
|
||||
<div class="line"><a id="l00052" name="l00052"></a><span class="lineno"> 52</span> }</div>
|
||||
@@ -151,7 +152,7 @@ $(function(){initNavTree('d0/d51/approximate__pi_8cpp_source.html','../../'); in
|
||||
<div class="line"><a id="l00055" name="l00055"></a><span class="lineno"> 55</span>}</div>
|
||||
</div>
|
||||
<div class="line"><a id="l00056" name="l00056"></a><span class="lineno"> 56</span>} <span class="comment">// namespace math</span></div>
|
||||
<div class="line"><a id="l00057" name="l00057"></a><span class="lineno"> 57</span> </div>
|
||||
<div class="line"><a id="l00057" name="l00057"></a><span class="lineno"> 57</span></div>
|
||||
<div class="foldopen" id="foldopen00062" data-start="{" data-end="}">
|
||||
<div class="line"><a id="l00062" name="l00062"></a><span class="lineno"><a class="line" href="../../d0/d51/approximate__pi_8cpp.html#a483bb8ccf42aaf7375a83e91490eda1e"> 62</a></span><span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code hl_function" href="../../d0/d51/approximate__pi_8cpp.html#a483bb8ccf42aaf7375a83e91490eda1e">tests</a>() {</div>
|
||||
<div class="line"><a id="l00063" name="l00063"></a><span class="lineno"> 63</span> std::vector<math::Point> rands;</div>
|
||||
@@ -167,7 +168,7 @@ $(function(){initNavTree('d0/d51/approximate__pi_8cpp_source.html','../../'); in
|
||||
<div class="line"><a id="l00073" name="l00073"></a><span class="lineno"> 73</span> std::cout << <span class="stringliteral">"All tests have successfully passed!"</span> << std::endl;</div>
|
||||
<div class="line"><a id="l00074" name="l00074"></a><span class="lineno"> 74</span>}</div>
|
||||
</div>
|
||||
<div class="line"><a id="l00075" name="l00075"></a><span class="lineno"> 75</span> </div>
|
||||
<div class="line"><a id="l00075" name="l00075"></a><span class="lineno"> 75</span></div>
|
||||
<div class="foldopen" id="foldopen00080" data-start="{" data-end="}">
|
||||
<div class="line"><a id="l00080" name="l00080"></a><span class="lineno"><a class="line" href="../../d0/d51/approximate__pi_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4"> 80</a></span><span class="keywordtype">int</span> <a class="code hl_function" href="../../d0/d51/approximate__pi_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4">main</a>() {</div>
|
||||
<div class="line"><a id="l00081" name="l00081"></a><span class="lineno"> 81</span> <a class="code hl_function" href="../../d0/d51/approximate__pi_8cpp.html#a483bb8ccf42aaf7375a83e91490eda1e">tests</a>(); <span class="comment">// run self-test implementations</span></div>
|
||||
@@ -178,15 +179,14 @@ $(function(){initNavTree('d0/d51/approximate__pi_8cpp_source.html','../../'); in
|
||||
<div class="ttc" id="aapproximate__pi_8cpp_html_ae66f6b31b5ad750f1fe042a706a4e3d4"><div class="ttname"><a href="../../d0/d51/approximate__pi_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4">main</a></div><div class="ttdeci">int main()</div><div class="ttdoc">Main function.</div><div class="ttdef"><b>Definition</b> <a href="#l00080">approximate_pi.cpp:80</a></div></div>
|
||||
<div class="ttc" id="anamespacemath_html"><div class="ttname"><a href="../../dd/d47/namespacemath.html">math</a></div><div class="ttdoc">for assert</div></div>
|
||||
<div class="ttc" id="anamespacemath_html_a006c8ebd11bb1e035815dc835a1a7a85"><div class="ttname"><a href="../../dd/d47/namespacemath.html#a006c8ebd11bb1e035815dc835a1a7a85">math::Point</a></div><div class="ttdeci">struct { double x; double y;} Point</div><div class="ttdoc">structure of points containing two numbers, x and y, such that 0 ≤ x ≤ 1 and 0 ≤ y ≤ 1.</div><div class="ttdef"><b>Definition</b> <a href="#l00035">approximate_pi.cpp:35</a></div></div>
|
||||
<div class="ttc" id="anamespacemath_html_abf7f2a6d91f1ca6c89698792aea3f188"><div class="ttname"><a href="../../dd/d47/namespacemath.html#abf7f2a6d91f1ca6c89698792aea3f188">math::approximate_pi</a></div><div class="ttdeci">double approximate_pi(const std::vector< Point > &pts)</div><div class="ttdoc">This function uses the points in a given vector 'pts' (drawn at random) to return an approximation of...</div><div class="ttdef"><b>Definition</b> <a href="#l00047">approximate_pi.cpp:47</a></div></div>
|
||||
<div class="ttc" id="astruct_point_html"><div class="ttname"><a href="../../d8/dc8/struct_point.html">Point</a></div><div class="ttdef"><b>Definition</b> <a href="../../d8/d6c/line__segment__intersection_8cpp_source.html#l00012">line_segment_intersection.cpp:12</a></div></div>
|
||||
<div class="ttc" id="anamespacemath_html_abf7f2a6d91f1ca6c89698792aea3f188"><div class="ttname"><a href="../../dd/d47/namespacemath.html#abf7f2a6d91f1ca6c89698792aea3f188">math::approximate_pi</a></div><div class="ttdeci">double approximate_pi(const std::vector< Point > &pts)</div><div class="ttdoc">This function uses the points in a given vector 'pts' (drawn at random) to return an approximation of...</div><div class="ttdef"><b>Definition</b> <a href="#l00047">approximate_pi.cpp:47</a></div></div>
|
||||
</div><!-- fragment --></div><!-- contents -->
|
||||
</div><!-- doc-content -->
|
||||
<!-- start footer part -->
|
||||
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
|
||||
<ul>
|
||||
<li class="navelem"><a class="el" href="../../dir_296d53ceaeaa7e099814a6def439fe8a.html">math</a></li><li class="navelem"><a class="el" href="../../d0/d51/approximate__pi_8cpp.html">approximate_pi.cpp</a></li>
|
||||
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="../../doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.12.0 </li>
|
||||
<li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="../../doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.13.2 </li>
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user