mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-05-11 19:17:21 +08:00
Documentation for 8b1eab204b
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
<!-- HTML header for doxygen 1.12.0-->
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
|
||||
<head>
|
||||
@@ -5,10 +6,15 @@
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
|
||||
<meta name="generator" content="Doxygen 1.12.0"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<title>Algorithms_in_C++: math/power_for_huge_numbers.cpp File Reference</title>
|
||||
<title>TheAlgorithms/C++: math/power_for_huge_numbers.cpp File Reference</title>
|
||||
<link rel="icon" href="../../favicon.svg" type="image/x-icon" />
|
||||
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="../../jquery.js"></script>
|
||||
<script type="text/javascript" src="../../dynsections.js"></script>
|
||||
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@xpack-3rd-party/doxygen-awesome-css@2.2.0-1/doxygen-awesome-darkmode-toggle.js"></script>
|
||||
<script type="text/javascript">
|
||||
DoxygenAwesomeDarkModeToggle.init()
|
||||
</script>
|
||||
<script type="text/javascript" src="../../clipboard.js"></script>
|
||||
<link href="../../navtree.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="../../navtreedata.js"></script>
|
||||
@@ -18,14 +24,24 @@
|
||||
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="../../search/searchdata.js"></script>
|
||||
<script type="text/javascript" src="../../search/search.js"></script>
|
||||
<script type="text/x-mathjax-config">
|
||||
MathJax.Hub.Config({
|
||||
extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
|
||||
jax: ["input/TeX","output/HTML-CSS"],
|
||||
});
|
||||
<script type="text/javascript">
|
||||
window.MathJax = {
|
||||
options: {
|
||||
ignoreHtmlClass: 'tex2jax_ignore',
|
||||
processHtmlClass: 'tex2jax_process'
|
||||
},
|
||||
loader: {
|
||||
load: ['[tex]/ams']
|
||||
},
|
||||
tex: {
|
||||
macros: {},
|
||||
packages: ['base','configmacros','ams']
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<script type="text/javascript" async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-MML-AM_CHTML/MathJax.js"></script>
|
||||
<script type="text/javascript" id="MathJax-script" async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"></script>
|
||||
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
|
||||
<link href="../../doxygen-awesome.css" rel="stylesheet" type="text/css"/>
|
||||
</head>
|
||||
<body>
|
||||
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
||||
@@ -33,10 +49,11 @@ MathJax.Hub.Config({
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<tbody>
|
||||
<tr id="projectrow">
|
||||
<td id="projectlogo"><img alt="Logo" src="../../project_logo.png"/></td>
|
||||
<td id="projectalign">
|
||||
<div id="projectname">Algorithms_in_C++<span id="projectnumber"> 1.0.0</span>
|
||||
<div id="projectname">TheAlgorithms/C++<span id="projectnumber"> 1.0.0</span>
|
||||
</div>
|
||||
<div id="projectbrief">Set of algorithms implemented in C++.</div>
|
||||
<div id="projectbrief">All the algorithms implemented in C++</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@@ -119,7 +136,9 @@ Include dependency graph for power_for_huge_numbers.cpp:</div>
|
||||
<div class="dyncontent">
|
||||
<div class="center"><iframe scrolling="no" frameborder="0" src="../../d7/d8e/power__for__huge__numbers_8cpp__incl.svg" width="158" height="126"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
|
||||
</div>
|
||||
</div><table class="memberdecls">
|
||||
</div>
|
||||
<p><a href="../../df/def/power__for__huge__numbers_8cpp_source.html">Go to the source code of this file.</a></p>
|
||||
<table class="memberdecls">
|
||||
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="define-members" name="define-members"></a>
|
||||
Macros</h2></td></tr>
|
||||
<tr class="memitem:a392fb874e547e582e9c66a08a1f23326" id="r_a392fb874e547e582e9c66a08a1f23326"><td class="memItemLeft" align="right" valign="top">#define </td><td class="memItemRight" valign="bottom"><a class="el" href="#a392fb874e547e582e9c66a08a1f23326">MAX</a>   100000</td></tr>
|
||||
@@ -136,6 +155,8 @@ Functions</h2></td></tr>
|
||||
</table>
|
||||
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
|
||||
<div class="textblock"><p>Compute powers of large numbers. </p>
|
||||
|
||||
<p class="definition">Definition in file <a class="el" href="../../df/def/power__for__huge__numbers_8cpp_source.html">power_for_huge_numbers.cpp</a>.</p>
|
||||
</div><h2 class="groupheader">Macro Definition Documentation</h2>
|
||||
<a id="a392fb874e547e582e9c66a08a1f23326" name="a392fb874e547e582e9c66a08a1f23326"></a>
|
||||
<h2 class="memtitle"><span class="permalink"><a href="#a392fb874e547e582e9c66a08a1f23326">◆ </a></span>MAX</h2>
|
||||
@@ -150,6 +171,8 @@ Functions</h2></td></tr>
|
||||
</div><div class="memdoc">
|
||||
<p>Maximum number of digits in output \(x^n\) where \(1 <= x,\; n <= 10000\) and overflow may happen </p>
|
||||
|
||||
<p class="definition">Definition at line <a class="el" href="../../df/def/power__for__huge__numbers_8cpp_source.html#l00010">10</a> of file <a class="el" href="../../df/def/power__for__huge__numbers_8cpp_source.html">power_for_huge_numbers.cpp</a>.</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<h2 class="groupheader">Function Documentation</h2>
|
||||
@@ -168,24 +191,19 @@ Functions</h2></td></tr>
|
||||
</table>
|
||||
</div><div class="memdoc">
|
||||
<p>Main function </p>
|
||||
|
||||
<p class="definition">Definition at line <a class="el" href="../../df/def/power__for__huge__numbers_8cpp_source.html#l00082">82</a> of file <a class="el" href="../../df/def/power__for__huge__numbers_8cpp_source.html">power_for_huge_numbers.cpp</a>.</p>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 82</span> {</div>
|
||||
<div class="line"><span class="lineno"> 83</span> <span class="keywordtype">int</span> exponent, base;</div>
|
||||
<div class="line"><span class="lineno"> 84</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"Enter base "</span>;</div>
|
||||
<div class="line"><span class="lineno"> 85</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_istream.html">std::cin</a> >> base;</div>
|
||||
<div class="line"><span class="lineno"> 86</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"Enter exponent "</span>;</div>
|
||||
<div class="line"><span class="lineno"> 87</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_istream.html">std::cin</a> >> exponent;</div>
|
||||
<div class="line"><span class="lineno"> 84</span> std::cout << <span class="stringliteral">"Enter base "</span>;</div>
|
||||
<div class="line"><span class="lineno"> 85</span> std::cin >> base;</div>
|
||||
<div class="line"><span class="lineno"> 86</span> std::cout << <span class="stringliteral">"Enter exponent "</span>;</div>
|
||||
<div class="line"><span class="lineno"> 87</span> std::cin >> exponent;</div>
|
||||
<div class="line"><span class="lineno"> 88</span> <a class="code hl_function" href="#ae249a2af508aa94266023ce8aa81426f">power</a>(base, exponent);</div>
|
||||
<div class="line"><span class="lineno"> 89</span> <span class="keywordflow">return</span> 0;</div>
|
||||
<div class="line"><span class="lineno"> 90</span>}</div>
|
||||
<div class="ttc" id="abasic_istream_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/io/basic_istream.html">std::cin</a></div></div>
|
||||
<div class="ttc" id="abasic_ostream_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a></div></div>
|
||||
<div class="ttc" id="apower__for__huge__numbers_8cpp_html_ae249a2af508aa94266023ce8aa81426f"><div class="ttname"><a href="#ae249a2af508aa94266023ce8aa81426f">power</a></div><div class="ttdeci">void power(int x, int n)</div><div class="ttdef"><b>Definition</b> power_for_huge_numbers.cpp:56</div></div>
|
||||
</div><!-- fragment --><div class="dynheader">
|
||||
Here is the call graph for this function:</div>
|
||||
<div class="dyncontent">
|
||||
<div class="center"><iframe scrolling="no" frameborder="0" src="../../df/def/power__for__huge__numbers_8cpp_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg" width="279" height="36"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
|
||||
</div>
|
||||
|
||||
<div class="ttc" id="apower__for__huge__numbers_8cpp_html_ae249a2af508aa94266023ce8aa81426f"><div class="ttname"><a href="#ae249a2af508aa94266023ce8aa81426f">power</a></div><div class="ttdeci">void power(int x, int n)</div><div class="ttdef"><b>Definition</b> <a href="../../df/def/power__for__huge__numbers_8cpp_source.html#l00056">power_for_huge_numbers.cpp:56</a></div></div>
|
||||
</div><!-- fragment -->
|
||||
</div>
|
||||
</div>
|
||||
<a id="aa141a7904f0c4668bac112d652a3acf9" name="aa141a7904f0c4668bac112d652a3acf9"></a>
|
||||
@@ -219,6 +237,8 @@ Here is the call graph for this function:</div>
|
||||
</table>
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<p class="definition">Definition at line <a class="el" href="../../df/def/power__for__huge__numbers_8cpp_source.html#l00025">25</a> of file <a class="el" href="../../df/def/power__for__huge__numbers_8cpp_source.html">power_for_huge_numbers.cpp</a>.</p>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 25</span> {</div>
|
||||
<div class="line"><span class="lineno"> 26</span> <span class="comment">// Initialize carry</span></div>
|
||||
<div class="line"><span class="lineno"> 27</span> <span class="keywordtype">int</span> carry = 0;</div>
|
||||
@@ -273,10 +293,12 @@ Here is the call graph for this function:</div>
|
||||
</table>
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<p class="definition">Definition at line <a class="el" href="../../df/def/power__for__huge__numbers_8cpp_source.html#l00056">56</a> of file <a class="el" href="../../df/def/power__for__huge__numbers_8cpp_source.html">power_for_huge_numbers.cpp</a>.</p>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 56</span> {</div>
|
||||
<div class="line"><span class="lineno"> 57</span> <span class="comment">// printing value "1" for power = 0</span></div>
|
||||
<div class="line"><span class="lineno"> 58</span> <span class="keywordflow">if</span> (n == 0) {</div>
|
||||
<div class="line"><span class="lineno"> 59</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"1"</span>;</div>
|
||||
<div class="line"><span class="lineno"> 59</span> std::cout << <span class="stringliteral">"1"</span>;</div>
|
||||
<div class="line"><span class="lineno"> 60</span> <span class="keywordflow">return</span>;</div>
|
||||
<div class="line"><span class="lineno"> 61</span> }</div>
|
||||
<div class="line"><span class="lineno"> 62</span> </div>
|
||||
@@ -294,17 +316,12 @@ Here is the call graph for this function:</div>
|
||||
<div class="line"><span class="lineno"> 74</span> <span class="comment">// (x^n = x*x*x....n times)</span></div>
|
||||
<div class="line"><span class="lineno"> 75</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 2; i <= n; i++) res_size = <a class="code hl_function" href="#aa141a7904f0c4668bac112d652a3acf9">multiply</a>(x, res, res_size);</div>
|
||||
<div class="line"><span class="lineno"> 76</span> </div>
|
||||
<div class="line"><span class="lineno"> 77</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << x << <span class="stringliteral">"^"</span> << n << <span class="stringliteral">" = "</span>;</div>
|
||||
<div class="line"><span class="lineno"> 78</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = res_size - 1; i >= 0; i--) <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << res[i];</div>
|
||||
<div class="line"><span class="lineno"> 77</span> std::cout << x << <span class="stringliteral">"^"</span> << n << <span class="stringliteral">" = "</span>;</div>
|
||||
<div class="line"><span class="lineno"> 78</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = res_size - 1; i >= 0; i--) std::cout << res[i];</div>
|
||||
<div class="line"><span class="lineno"> 79</span>}</div>
|
||||
<div class="ttc" id="apower__for__huge__numbers_8cpp_html_a392fb874e547e582e9c66a08a1f23326"><div class="ttname"><a href="#a392fb874e547e582e9c66a08a1f23326">MAX</a></div><div class="ttdeci">#define MAX</div><div class="ttdef"><b>Definition</b> power_for_huge_numbers.cpp:10</div></div>
|
||||
<div class="ttc" id="apower__for__huge__numbers_8cpp_html_aa141a7904f0c4668bac112d652a3acf9"><div class="ttname"><a href="#aa141a7904f0c4668bac112d652a3acf9">multiply</a></div><div class="ttdeci">int multiply(int x, int res[], int res_size)</div><div class="ttdef"><b>Definition</b> power_for_huge_numbers.cpp:25</div></div>
|
||||
</div><!-- fragment --><div class="dynheader">
|
||||
Here is the call graph for this function:</div>
|
||||
<div class="dyncontent">
|
||||
<div class="center"><iframe scrolling="no" frameborder="0" src="../../df/def/power__for__huge__numbers_8cpp_ae249a2af508aa94266023ce8aa81426f_cgraph.svg" width="182" height="36"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div>
|
||||
</div>
|
||||
|
||||
<div class="ttc" id="apower__for__huge__numbers_8cpp_html_a392fb874e547e582e9c66a08a1f23326"><div class="ttname"><a href="#a392fb874e547e582e9c66a08a1f23326">MAX</a></div><div class="ttdeci">#define MAX</div><div class="ttdef"><b>Definition</b> <a href="../../df/def/power__for__huge__numbers_8cpp_source.html#l00010">power_for_huge_numbers.cpp:10</a></div></div>
|
||||
<div class="ttc" id="apower__for__huge__numbers_8cpp_html_aa141a7904f0c4668bac112d652a3acf9"><div class="ttname"><a href="#aa141a7904f0c4668bac112d652a3acf9">multiply</a></div><div class="ttdeci">int multiply(int x, int res[], int res_size)</div><div class="ttdef"><b>Definition</b> <a href="../../df/def/power__for__huge__numbers_8cpp_source.html#l00025">power_for_huge_numbers.cpp:25</a></div></div>
|
||||
</div><!-- fragment -->
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- contents -->
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
<map id="power" name="power">
|
||||
<area shape="rect" id="Node000001" title=" " alt="" coords="5,5,62,31"/>
|
||||
<area shape="rect" id="Node000002" href="$df/def/power__for__huge__numbers_8cpp.html#aa141a7904f0c4668bac112d652a3acf9" title=" " alt="" coords="110,5,176,31"/>
|
||||
<area shape="poly" id="edge1_Node000001_Node000002" title=" " alt="" coords="62,16,94,16,94,21,62,21"/>
|
||||
</map>
|
||||
@@ -1 +0,0 @@
|
||||
bca904e090a799dbfda5d017822f5ace
|
||||
@@ -1,65 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<!-- Generated by graphviz version 12.1.2 (20240928.0832)
|
||||
-->
|
||||
<!-- Title: power Pages: 1 -->
|
||||
<svg width="136pt" height="27pt"
|
||||
viewBox="0.00 0.00 136.00 27.25" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
|
||||
<svg id="main" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve">
|
||||
|
||||
<style type="text/css"><![CDATA[
|
||||
.node, .edge {opacity: 0.7;}
|
||||
.node.selected, .edge.selected {opacity: 1;}
|
||||
.edge:hover path { stroke: red; }
|
||||
.edge:hover polygon { stroke: red; fill: red; }
|
||||
]]></style>
|
||||
<script type="application/ecmascript" xlink:href="../../svg.min.js"/>
|
||||
<svg id="graph" class="graph">
|
||||
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 23.25)">
|
||||
<title>power</title>
|
||||
<!-- Node1 -->
|
||||
<g id="Node000001" class="node">
|
||||
<title>Node1</title>
|
||||
<g id="a_Node000001"><a xlink:title=" ">
|
||||
<polygon fill="#999999" stroke="#666666" points="42.25,-19.25 0,-19.25 0,0 42.25,0 42.25,-19.25"/>
|
||||
<text text-anchor="middle" x="21.12" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">power</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node2 -->
|
||||
<g id="Node000002" class="node">
|
||||
<title>Node2</title>
|
||||
<g id="a_Node000002"><a xlink:href="../../df/def/power__for__huge__numbers_8cpp.html#aa141a7904f0c4668bac112d652a3acf9" target="_top" xlink:title=" ">
|
||||
<polygon fill="white" stroke="#666666" points="128,-19.25 78.25,-19.25 78.25,0 128,0 128,-19.25"/>
|
||||
<text text-anchor="middle" x="103.12" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">multiply</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node1->Node2 -->
|
||||
<g id="edge1_Node000001_Node000002" class="edge">
|
||||
<title>Node1->Node2</title>
|
||||
<g id="a_edge1_Node000001_Node000002"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M42.73,-9.62C50.03,-9.62 58.46,-9.62 66.65,-9.62"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="66.38,-13.13 76.38,-9.63 66.38,-6.13 66.38,-13.13"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
</svg>
|
||||
|
||||
<style type='text/css'>
|
||||
<![CDATA[
|
||||
[data-mouse-over-selected='false'] { opacity: 0.7; }
|
||||
[data-mouse-over-selected='true'] { opacity: 1.0; }
|
||||
]]>
|
||||
</style>
|
||||
<script type="application/ecmascript"><![CDATA[
|
||||
document.addEventListener('DOMContentLoaded', (event) => {
|
||||
highlightEdges();
|
||||
highlightAdjacentNodes();
|
||||
});
|
||||
]]></script>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 2.4 KiB |
@@ -1,39 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<!-- Generated by graphviz version 12.1.2 (20240928.0832)
|
||||
-->
|
||||
<!-- Title: power Pages: 1 -->
|
||||
<svg width="136pt" height="27pt"
|
||||
viewBox="0.00 0.00 136.00 27.25" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 23.25)">
|
||||
<title>power</title>
|
||||
<!-- Node1 -->
|
||||
<g id="Node000001" class="node">
|
||||
<title>Node1</title>
|
||||
<g id="a_Node000001"><a xlink:title=" ">
|
||||
<polygon fill="#999999" stroke="#666666" points="42.25,-19.25 0,-19.25 0,0 42.25,0 42.25,-19.25"/>
|
||||
<text text-anchor="middle" x="21.12" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">power</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node2 -->
|
||||
<g id="Node000002" class="node">
|
||||
<title>Node2</title>
|
||||
<g id="a_Node000002"><a xlink:href="../../df/def/power__for__huge__numbers_8cpp.html#aa141a7904f0c4668bac112d652a3acf9" target="_top" xlink:title=" ">
|
||||
<polygon fill="white" stroke="#666666" points="128,-19.25 78.25,-19.25 78.25,0 128,0 128,-19.25"/>
|
||||
<text text-anchor="middle" x="103.12" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">multiply</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node1->Node2 -->
|
||||
<g id="edge1_Node000001_Node000002" class="edge">
|
||||
<title>Node1->Node2</title>
|
||||
<g id="a_edge1_Node000001_Node000002"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M42.73,-9.62C50.03,-9.62 58.46,-9.62 66.65,-9.62"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="66.38,-13.13 76.38,-9.63 66.38,-6.13 66.38,-13.13"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 1.6 KiB |
@@ -1,7 +0,0 @@
|
||||
<map id="main" name="main">
|
||||
<area shape="rect" id="Node000001" title=" " alt="" coords="5,5,55,31"/>
|
||||
<area shape="rect" id="Node000002" href="$df/def/power__for__huge__numbers_8cpp.html#ae249a2af508aa94266023ce8aa81426f" title=" " alt="" coords="103,5,159,31"/>
|
||||
<area shape="poly" id="edge1_Node000001_Node000002" title=" " alt="" coords="55,16,87,16,87,21,55,21"/>
|
||||
<area shape="rect" id="Node000003" href="$df/def/power__for__huge__numbers_8cpp.html#aa141a7904f0c4668bac112d652a3acf9" title=" " alt="" coords="207,5,273,31"/>
|
||||
<area shape="poly" id="edge2_Node000002_Node000003" title=" " alt="" coords="160,16,192,16,192,21,160,21"/>
|
||||
</map>
|
||||
@@ -1 +0,0 @@
|
||||
6c2f49db8978fbaa55feafa3a142af7c
|
||||
@@ -1,83 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<!-- Generated by graphviz version 12.1.2 (20240928.0832)
|
||||
-->
|
||||
<!-- Title: main Pages: 1 -->
|
||||
<svg width="209pt" height="27pt"
|
||||
viewBox="0.00 0.00 209.00 27.25" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
|
||||
<svg id="main" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve">
|
||||
|
||||
<style type="text/css"><![CDATA[
|
||||
.node, .edge {opacity: 0.7;}
|
||||
.node.selected, .edge.selected {opacity: 1;}
|
||||
.edge:hover path { stroke: red; }
|
||||
.edge:hover polygon { stroke: red; fill: red; }
|
||||
]]></style>
|
||||
<script type="application/ecmascript" xlink:href="../../svg.min.js"/>
|
||||
<svg id="graph" class="graph">
|
||||
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 23.25)">
|
||||
<title>main</title>
|
||||
<!-- Node1 -->
|
||||
<g id="Node000001" class="node">
|
||||
<title>Node1</title>
|
||||
<g id="a_Node000001"><a xlink:title=" ">
|
||||
<polygon fill="#999999" stroke="#666666" points="37,-19.25 0,-19.25 0,0 37,0 37,-19.25"/>
|
||||
<text text-anchor="middle" x="18.5" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">main</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node2 -->
|
||||
<g id="Node000002" class="node">
|
||||
<title>Node2</title>
|
||||
<g id="a_Node000002"><a xlink:href="../../df/def/power__for__huge__numbers_8cpp.html#ae249a2af508aa94266023ce8aa81426f" target="_top" xlink:title=" ">
|
||||
<polygon fill="white" stroke="#666666" points="115.25,-19.25 73,-19.25 73,0 115.25,0 115.25,-19.25"/>
|
||||
<text text-anchor="middle" x="94.12" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">power</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node1->Node2 -->
|
||||
<g id="edge1_Node000001_Node000002" class="edge">
|
||||
<title>Node1->Node2</title>
|
||||
<g id="a_edge1_Node000001_Node000002"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M37.32,-9.62C44.55,-9.62 53.13,-9.62 61.37,-9.62"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="61.09,-13.13 71.09,-9.63 61.09,-6.13 61.09,-13.13"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node3 -->
|
||||
<g id="Node000003" class="node">
|
||||
<title>Node3</title>
|
||||
<g id="a_Node000003"><a xlink:href="../../df/def/power__for__huge__numbers_8cpp.html#aa141a7904f0c4668bac112d652a3acf9" target="_top" xlink:title=" ">
|
||||
<polygon fill="white" stroke="#666666" points="201,-19.25 151.25,-19.25 151.25,0 201,0 201,-19.25"/>
|
||||
<text text-anchor="middle" x="176.12" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">multiply</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node2->Node3 -->
|
||||
<g id="edge2_Node000002_Node000003" class="edge">
|
||||
<title>Node2->Node3</title>
|
||||
<g id="a_edge2_Node000002_Node000003"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M115.73,-9.62C123.03,-9.62 131.46,-9.62 139.65,-9.62"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="139.38,-13.13 149.38,-9.63 139.38,-6.13 139.38,-13.13"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
</svg>
|
||||
|
||||
<style type='text/css'>
|
||||
<![CDATA[
|
||||
[data-mouse-over-selected='false'] { opacity: 0.7; }
|
||||
[data-mouse-over-selected='true'] { opacity: 1.0; }
|
||||
]]>
|
||||
</style>
|
||||
<script type="application/ecmascript"><![CDATA[
|
||||
document.addEventListener('DOMContentLoaded', (event) => {
|
||||
highlightEdges();
|
||||
highlightAdjacentNodes();
|
||||
});
|
||||
]]></script>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 3.2 KiB |
@@ -1,57 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<!-- Generated by graphviz version 12.1.2 (20240928.0832)
|
||||
-->
|
||||
<!-- Title: main Pages: 1 -->
|
||||
<svg width="209pt" height="27pt"
|
||||
viewBox="0.00 0.00 209.00 27.25" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 23.25)">
|
||||
<title>main</title>
|
||||
<!-- Node1 -->
|
||||
<g id="Node000001" class="node">
|
||||
<title>Node1</title>
|
||||
<g id="a_Node000001"><a xlink:title=" ">
|
||||
<polygon fill="#999999" stroke="#666666" points="37,-19.25 0,-19.25 0,0 37,0 37,-19.25"/>
|
||||
<text text-anchor="middle" x="18.5" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">main</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node2 -->
|
||||
<g id="Node000002" class="node">
|
||||
<title>Node2</title>
|
||||
<g id="a_Node000002"><a xlink:href="../../df/def/power__for__huge__numbers_8cpp.html#ae249a2af508aa94266023ce8aa81426f" target="_top" xlink:title=" ">
|
||||
<polygon fill="white" stroke="#666666" points="115.25,-19.25 73,-19.25 73,0 115.25,0 115.25,-19.25"/>
|
||||
<text text-anchor="middle" x="94.12" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">power</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node1->Node2 -->
|
||||
<g id="edge1_Node000001_Node000002" class="edge">
|
||||
<title>Node1->Node2</title>
|
||||
<g id="a_edge1_Node000001_Node000002"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M37.32,-9.62C44.55,-9.62 53.13,-9.62 61.37,-9.62"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="61.09,-13.13 71.09,-9.63 61.09,-6.13 61.09,-13.13"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node3 -->
|
||||
<g id="Node000003" class="node">
|
||||
<title>Node3</title>
|
||||
<g id="a_Node000003"><a xlink:href="../../df/def/power__for__huge__numbers_8cpp.html#aa141a7904f0c4668bac112d652a3acf9" target="_top" xlink:title=" ">
|
||||
<polygon fill="white" stroke="#666666" points="201,-19.25 151.25,-19.25 151.25,0 201,0 201,-19.25"/>
|
||||
<text text-anchor="middle" x="176.12" y="-5.75" font-family="Helvetica,sans-Serif" font-size="10.00">multiply</text>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
<!-- Node2->Node3 -->
|
||||
<g id="edge2_Node000002_Node000003" class="edge">
|
||||
<title>Node2->Node3</title>
|
||||
<g id="a_edge2_Node000002_Node000003"><a xlink:title=" ">
|
||||
<path fill="none" stroke="#63b8ff" d="M115.73,-9.62C123.03,-9.62 131.46,-9.62 139.65,-9.62"/>
|
||||
<polygon fill="#63b8ff" stroke="#63b8ff" points="139.38,-13.13 149.38,-9.63 139.38,-6.13 139.38,-13.13"/>
|
||||
</a>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 2.4 KiB |
213
df/def/power__for__huge__numbers_8cpp_source.html
Normal file
213
df/def/power__for__huge__numbers_8cpp_source.html
Normal file
@@ -0,0 +1,213 @@
|
||||
<!-- HTML header for doxygen 1.12.0-->
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
|
||||
<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="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<title>TheAlgorithms/C++: math/power_for_huge_numbers.cpp Source File</title>
|
||||
<link rel="icon" href="../../favicon.svg" type="image/x-icon" />
|
||||
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="../../jquery.js"></script>
|
||||
<script type="text/javascript" src="../../dynsections.js"></script>
|
||||
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@xpack-3rd-party/doxygen-awesome-css@2.2.0-1/doxygen-awesome-darkmode-toggle.js"></script>
|
||||
<script type="text/javascript">
|
||||
DoxygenAwesomeDarkModeToggle.init()
|
||||
</script>
|
||||
<script type="text/javascript" src="../../clipboard.js"></script>
|
||||
<link href="../../navtree.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="../../navtreedata.js"></script>
|
||||
<script type="text/javascript" src="../../navtree.js"></script>
|
||||
<script type="text/javascript" src="../../resize.js"></script>
|
||||
<script type="text/javascript" src="../../cookie.js"></script>
|
||||
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="../../search/searchdata.js"></script>
|
||||
<script type="text/javascript" src="../../search/search.js"></script>
|
||||
<script type="text/javascript">
|
||||
window.MathJax = {
|
||||
options: {
|
||||
ignoreHtmlClass: 'tex2jax_ignore',
|
||||
processHtmlClass: 'tex2jax_process'
|
||||
},
|
||||
loader: {
|
||||
load: ['[tex]/ams']
|
||||
},
|
||||
tex: {
|
||||
macros: {},
|
||||
packages: ['base','configmacros','ams']
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<script type="text/javascript" id="MathJax-script" async="async" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"></script>
|
||||
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
|
||||
<link href="../../doxygen-awesome.css" rel="stylesheet" type="text/css"/>
|
||||
</head>
|
||||
<body>
|
||||
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
||||
<div id="titlearea">
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<tbody>
|
||||
<tr id="projectrow">
|
||||
<td id="projectlogo"><img alt="Logo" src="../../project_logo.png"/></td>
|
||||
<td id="projectalign">
|
||||
<div id="projectname">TheAlgorithms/C++<span id="projectnumber"> 1.0.0</span>
|
||||
</div>
|
||||
<div id="projectbrief">All the algorithms implemented in C++</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!-- end header part -->
|
||||
<!-- Generated by Doxygen 1.12.0 -->
|
||||
<script type="text/javascript">
|
||||
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||||
var searchBox = new SearchBox("searchBox", "../../search/",'.html');
|
||||
/* @license-end */
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||||
$(function() { codefold.init(1); });
|
||||
/* @license-end */
|
||||
</script>
|
||||
<script type="text/javascript" src="../../menudata.js"></script>
|
||||
<script type="text/javascript" src="../../menu.js"></script>
|
||||
<script type="text/javascript">
|
||||
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||||
$(function() {
|
||||
initMenu('../../',true,false,'search.php','Search',true);
|
||||
$(function() { init_search(); });
|
||||
});
|
||||
/* @license-end */
|
||||
</script>
|
||||
<div id="main-nav"></div>
|
||||
</div><!-- top -->
|
||||
<div id="side-nav" class="ui-resizable side-nav-resizable">
|
||||
<div id="nav-tree">
|
||||
<div id="nav-tree-contents">
|
||||
<div id="nav-sync" class="sync"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="splitbar" style="-moz-user-select:none;"
|
||||
class="ui-resizable-handle">
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||||
$(function(){initNavTree('df/def/power__for__huge__numbers_8cpp_source.html','../../'); initResizable(true); });
|
||||
/* @license-end */
|
||||
</script>
|
||||
<div id="doc-content">
|
||||
<!-- window showing the filter options -->
|
||||
<div id="MSearchSelectWindow"
|
||||
onmouseover="return searchBox.OnSearchSelectShow()"
|
||||
onmouseout="return searchBox.OnSearchSelectHide()"
|
||||
onkeydown="return searchBox.OnSearchSelectKey(event)">
|
||||
</div>
|
||||
|
||||
<!-- iframe showing the search results (closed by default) -->
|
||||
<div id="MSearchResultsWindow">
|
||||
<div id="MSearchResults">
|
||||
<div class="SRPage">
|
||||
<div id="SRIndex">
|
||||
<div id="SRResults"></div>
|
||||
<div class="SRStatus" id="Loading">Loading...</div>
|
||||
<div class="SRStatus" id="Searching">Searching...</div>
|
||||
<div class="SRStatus" id="NoMatches">No Matches</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="header">
|
||||
<div class="headertitle"><div class="title">power_for_huge_numbers.cpp</div></div>
|
||||
</div><!--header-->
|
||||
<div class="contents">
|
||||
<a href="../../df/def/power__for__huge__numbers_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="l00005" name="l00005"></a><span class="lineno"> 5</span><span class="preprocessor">#include <iostream></span></div>
|
||||
<div class="line"><a id="l00006" name="l00006"></a><span class="lineno"> 6</span> </div>
|
||||
<div class="line"><a id="l00010" name="l00010"></a><span class="lineno"><a class="line" href="../../df/def/power__for__huge__numbers_8cpp.html#a392fb874e547e582e9c66a08a1f23326"> 10</a></span><span class="preprocessor">#define MAX 100000</span></div>
|
||||
<div class="line"><a id="l00011" name="l00011"></a><span class="lineno"> 11</span> </div>
|
||||
<div class="foldopen" id="foldopen00025" data-start="{" data-end="}">
|
||||
<div class="line"><a id="l00025" name="l00025"></a><span class="lineno"><a class="line" href="../../df/def/power__for__huge__numbers_8cpp.html#aa141a7904f0c4668bac112d652a3acf9"> 25</a></span><span class="keywordtype">int</span> <a class="code hl_function" href="../../df/def/power__for__huge__numbers_8cpp.html#aa141a7904f0c4668bac112d652a3acf9">multiply</a>(<span class="keywordtype">int</span> x, <span class="keywordtype">int</span> res[], <span class="keywordtype">int</span> res_size) {</div>
|
||||
<div class="line"><a id="l00026" name="l00026"></a><span class="lineno"> 26</span> <span class="comment">// Initialize carry</span></div>
|
||||
<div class="line"><a id="l00027" name="l00027"></a><span class="lineno"> 27</span> <span class="keywordtype">int</span> carry = 0;</div>
|
||||
<div class="line"><a id="l00028" name="l00028"></a><span class="lineno"> 28</span> </div>
|
||||
<div class="line"><a id="l00029" name="l00029"></a><span class="lineno"> 29</span> <span class="comment">// One by one multiply n with</span></div>
|
||||
<div class="line"><a id="l00030" name="l00030"></a><span class="lineno"> 30</span> <span class="comment">// individual digits of res[]</span></div>
|
||||
<div class="line"><a id="l00031" name="l00031"></a><span class="lineno"> 31</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < res_size; i++) {</div>
|
||||
<div class="line"><a id="l00032" name="l00032"></a><span class="lineno"> 32</span> <span class="keywordtype">int</span> prod = res[i] * x + carry;</div>
|
||||
<div class="line"><a id="l00033" name="l00033"></a><span class="lineno"> 33</span> </div>
|
||||
<div class="line"><a id="l00034" name="l00034"></a><span class="lineno"> 34</span> <span class="comment">// Store last digit of</span></div>
|
||||
<div class="line"><a id="l00035" name="l00035"></a><span class="lineno"> 35</span> <span class="comment">// 'prod' in res[]</span></div>
|
||||
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno"> 36</span> res[i] = prod % 10;</div>
|
||||
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno"> 37</span> </div>
|
||||
<div class="line"><a id="l00038" name="l00038"></a><span class="lineno"> 38</span> <span class="comment">// Put rest in carry</span></div>
|
||||
<div class="line"><a id="l00039" name="l00039"></a><span class="lineno"> 39</span> carry = prod / 10;</div>
|
||||
<div class="line"><a id="l00040" name="l00040"></a><span class="lineno"> 40</span> }</div>
|
||||
<div class="line"><a id="l00041" name="l00041"></a><span class="lineno"> 41</span> </div>
|
||||
<div class="line"><a id="l00042" name="l00042"></a><span class="lineno"> 42</span> <span class="comment">// Put carry in res and</span></div>
|
||||
<div class="line"><a id="l00043" name="l00043"></a><span class="lineno"> 43</span> <span class="comment">// increase result size</span></div>
|
||||
<div class="line"><a id="l00044" name="l00044"></a><span class="lineno"> 44</span> <span class="keywordflow">while</span> (carry) {</div>
|
||||
<div class="line"><a id="l00045" name="l00045"></a><span class="lineno"> 45</span> res[res_size] = carry % 10;</div>
|
||||
<div class="line"><a id="l00046" name="l00046"></a><span class="lineno"> 46</span> carry = carry / 10;</div>
|
||||
<div class="line"><a id="l00047" name="l00047"></a><span class="lineno"> 47</span> res_size++;</div>
|
||||
<div class="line"><a id="l00048" name="l00048"></a><span class="lineno"> 48</span> }</div>
|
||||
<div class="line"><a id="l00049" name="l00049"></a><span class="lineno"> 49</span> <span class="keywordflow">return</span> res_size;</div>
|
||||
<div class="line"><a id="l00050" name="l00050"></a><span class="lineno"> 50</span>}</div>
|
||||
</div>
|
||||
<div class="line"><a id="l00051" name="l00051"></a><span class="lineno"> 51</span> </div>
|
||||
<div class="foldopen" id="foldopen00056" data-start="{" data-end="}">
|
||||
<div class="line"><a id="l00056" name="l00056"></a><span class="lineno"><a class="line" href="../../df/def/power__for__huge__numbers_8cpp.html#ae249a2af508aa94266023ce8aa81426f"> 56</a></span><span class="keywordtype">void</span> <a class="code hl_function" href="../../df/def/power__for__huge__numbers_8cpp.html#ae249a2af508aa94266023ce8aa81426f">power</a>(<span class="keywordtype">int</span> x, <span class="keywordtype">int</span> n) {</div>
|
||||
<div class="line"><a id="l00057" name="l00057"></a><span class="lineno"> 57</span> <span class="comment">// printing value "1" for power = 0</span></div>
|
||||
<div class="line"><a id="l00058" name="l00058"></a><span class="lineno"> 58</span> <span class="keywordflow">if</span> (n == 0) {</div>
|
||||
<div class="line"><a id="l00059" name="l00059"></a><span class="lineno"> 59</span> std::cout << <span class="stringliteral">"1"</span>;</div>
|
||||
<div class="line"><a id="l00060" name="l00060"></a><span class="lineno"> 60</span> <span class="keywordflow">return</span>;</div>
|
||||
<div class="line"><a id="l00061" name="l00061"></a><span class="lineno"> 61</span> }</div>
|
||||
<div class="line"><a id="l00062" name="l00062"></a><span class="lineno"> 62</span> </div>
|
||||
<div class="line"><a id="l00063" name="l00063"></a><span class="lineno"> 63</span> <span class="keywordtype">int</span> res[<a class="code hl_define" href="../../df/def/power__for__huge__numbers_8cpp.html#a392fb874e547e582e9c66a08a1f23326">MAX</a>];</div>
|
||||
<div class="line"><a id="l00064" name="l00064"></a><span class="lineno"> 64</span> <span class="keywordtype">int</span> res_size = 0;</div>
|
||||
<div class="line"><a id="l00065" name="l00065"></a><span class="lineno"> 65</span> <span class="keywordtype">int</span> temp = x;</div>
|
||||
<div class="line"><a id="l00066" name="l00066"></a><span class="lineno"> 66</span> </div>
|
||||
<div class="line"><a id="l00067" name="l00067"></a><span class="lineno"> 67</span> <span class="comment">// Initialize result</span></div>
|
||||
<div class="line"><a id="l00068" name="l00068"></a><span class="lineno"> 68</span> <span class="keywordflow">while</span> (temp != 0) {</div>
|
||||
<div class="line"><a id="l00069" name="l00069"></a><span class="lineno"> 69</span> res[res_size++] = temp % 10;</div>
|
||||
<div class="line"><a id="l00070" name="l00070"></a><span class="lineno"> 70</span> temp = temp / 10;</div>
|
||||
<div class="line"><a id="l00071" name="l00071"></a><span class="lineno"> 71</span> }</div>
|
||||
<div class="line"><a id="l00072" name="l00072"></a><span class="lineno"> 72</span> </div>
|
||||
<div class="line"><a id="l00073" name="l00073"></a><span class="lineno"> 73</span> <span class="comment">// Multiply x n times</span></div>
|
||||
<div class="line"><a id="l00074" name="l00074"></a><span class="lineno"> 74</span> <span class="comment">// (x^n = x*x*x....n times)</span></div>
|
||||
<div class="line"><a id="l00075" name="l00075"></a><span class="lineno"> 75</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 2; i <= n; i++) res_size = <a class="code hl_function" href="../../df/def/power__for__huge__numbers_8cpp.html#aa141a7904f0c4668bac112d652a3acf9">multiply</a>(x, res, res_size);</div>
|
||||
<div class="line"><a id="l00076" name="l00076"></a><span class="lineno"> 76</span> </div>
|
||||
<div class="line"><a id="l00077" name="l00077"></a><span class="lineno"> 77</span> std::cout << x << <span class="stringliteral">"^"</span> << n << <span class="stringliteral">" = "</span>;</div>
|
||||
<div class="line"><a id="l00078" name="l00078"></a><span class="lineno"> 78</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = res_size - 1; i >= 0; i--) std::cout << res[i];</div>
|
||||
<div class="line"><a id="l00079" name="l00079"></a><span class="lineno"> 79</span>}</div>
|
||||
</div>
|
||||
<div class="line"><a id="l00080" name="l00080"></a><span class="lineno"> 80</span> </div>
|
||||
<div class="foldopen" id="foldopen00082" data-start="{" data-end="}">
|
||||
<div class="line"><a id="l00082" name="l00082"></a><span class="lineno"><a class="line" href="../../df/def/power__for__huge__numbers_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4"> 82</a></span><span class="keywordtype">int</span> <a class="code hl_function" href="../../df/def/power__for__huge__numbers_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4">main</a>() {</div>
|
||||
<div class="line"><a id="l00083" name="l00083"></a><span class="lineno"> 83</span> <span class="keywordtype">int</span> exponent, base;</div>
|
||||
<div class="line"><a id="l00084" name="l00084"></a><span class="lineno"> 84</span> std::cout << <span class="stringliteral">"Enter base "</span>;</div>
|
||||
<div class="line"><a id="l00085" name="l00085"></a><span class="lineno"> 85</span> std::cin >> base;</div>
|
||||
<div class="line"><a id="l00086" name="l00086"></a><span class="lineno"> 86</span> std::cout << <span class="stringliteral">"Enter exponent "</span>;</div>
|
||||
<div class="line"><a id="l00087" name="l00087"></a><span class="lineno"> 87</span> std::cin >> exponent;</div>
|
||||
<div class="line"><a id="l00088" name="l00088"></a><span class="lineno"> 88</span> <a class="code hl_function" href="../../df/def/power__for__huge__numbers_8cpp.html#ae249a2af508aa94266023ce8aa81426f">power</a>(base, exponent);</div>
|
||||
<div class="line"><a id="l00089" name="l00089"></a><span class="lineno"> 89</span> <span class="keywordflow">return</span> 0;</div>
|
||||
<div class="line"><a id="l00090" name="l00090"></a><span class="lineno"> 90</span>}</div>
|
||||
</div>
|
||||
<div class="ttc" id="apower__for__huge__numbers_8cpp_html_a392fb874e547e582e9c66a08a1f23326"><div class="ttname"><a href="../../df/def/power__for__huge__numbers_8cpp.html#a392fb874e547e582e9c66a08a1f23326">MAX</a></div><div class="ttdeci">#define MAX</div><div class="ttdef"><b>Definition</b> <a href="#l00010">power_for_huge_numbers.cpp:10</a></div></div>
|
||||
<div class="ttc" id="apower__for__huge__numbers_8cpp_html_aa141a7904f0c4668bac112d652a3acf9"><div class="ttname"><a href="../../df/def/power__for__huge__numbers_8cpp.html#aa141a7904f0c4668bac112d652a3acf9">multiply</a></div><div class="ttdeci">int multiply(int x, int res[], int res_size)</div><div class="ttdef"><b>Definition</b> <a href="#l00025">power_for_huge_numbers.cpp:25</a></div></div>
|
||||
<div class="ttc" id="apower__for__huge__numbers_8cpp_html_ae249a2af508aa94266023ce8aa81426f"><div class="ttname"><a href="../../df/def/power__for__huge__numbers_8cpp.html#ae249a2af508aa94266023ce8aa81426f">power</a></div><div class="ttdeci">void power(int x, int n)</div><div class="ttdef"><b>Definition</b> <a href="#l00056">power_for_huge_numbers.cpp:56</a></div></div>
|
||||
<div class="ttc" id="apower__for__huge__numbers_8cpp_html_ae66f6b31b5ad750f1fe042a706a4e3d4"><div class="ttname"><a href="../../df/def/power__for__huge__numbers_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4">main</a></div><div class="ttdeci">int main()</div><div class="ttdef"><b>Definition</b> <a href="#l00082">power_for_huge_numbers.cpp:82</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="../../df/def/power__for__huge__numbers_8cpp.html">power_for_huge_numbers.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>
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user