mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-03-24 22:02:20 +08:00
Documentation for 53a6c16730
This commit is contained in:
@@ -3,7 +3,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.9.2"/>
|
||||
<meta name="generator" content="Doxygen 1.9.3"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<title>Algorithms_in_C++: others/vector_important_functions.cpp File Reference</title>
|
||||
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
|
||||
@@ -30,8 +30,8 @@ MathJax.Hub.Config({
|
||||
<div id="titlearea">
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<tbody>
|
||||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<tr id="projectrow">
|
||||
<td id="projectalign">
|
||||
<div id="projectname">Algorithms_in_C++<span id="projectnumber"> 1.0.0</span>
|
||||
</div>
|
||||
<div id="projectbrief">Set of algorithms implemented in C++.</div>
|
||||
@@ -41,7 +41,7 @@ MathJax.Hub.Config({
|
||||
</table>
|
||||
</div>
|
||||
<!-- end header part -->
|
||||
<!-- Generated by Doxygen 1.9.2 -->
|
||||
<!-- Generated by Doxygen 1.9.3 -->
|
||||
<script type="text/javascript">
|
||||
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
|
||||
var searchBox = new SearchBox("searchBox", "../../search",'Search','.html');
|
||||
@@ -133,46 +133,46 @@ Functions</h2></td></tr>
|
||||
</table>
|
||||
</div><div class="memdoc">
|
||||
<p >Main function </p>
|
||||
<div class="fragment"><div class="line"><a id="l00011" name="l00011"></a><span class="lineno"> 11</span> {</div>
|
||||
<div class="line"><a id="l00012" name="l00012"></a><span class="lineno"> 12</span> <span class="comment">// Initializing vector with array values</span></div>
|
||||
<div class="line"><a id="l00013" name="l00013"></a><span class="lineno"> 13</span> <span class="keywordtype">int</span> arr[] = {10, 20, 5, 23, 42, 15};</div>
|
||||
<div class="line"><a id="l00014" name="l00014"></a><span class="lineno"> 14</span> <span class="keywordtype">int</span> n = <span class="keyword">sizeof</span>(arr) / <span class="keyword">sizeof</span>(arr[0]);</div>
|
||||
<div class="line"><a id="l00015" name="l00015"></a><span class="lineno"> 15</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector<int></a> vect(arr, arr + n);</div>
|
||||
<div class="line"><a id="l00016" name="l00016"></a><span class="lineno"> 16</span> </div>
|
||||
<div class="line"><a id="l00017" name="l00017"></a><span class="lineno"> 17</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">"Vector is: "</span>;</div>
|
||||
<div class="line"><a id="l00018" name="l00018"></a><span class="lineno"> 18</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < n; i++) <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << vect[i] << <span class="stringliteral">" "</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="comment">// Sorting the Vector in Ascending order</span></div>
|
||||
<div class="line"><a id="l00021" name="l00021"></a><span class="lineno"> 21</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/sort.html">std::sort</a>(vect.begin(), vect.end());</div>
|
||||
<div class="line"><a id="l00022" name="l00022"></a><span class="lineno"> 22</span> </div>
|
||||
<div class="line"><a id="l00023" name="l00023"></a><span class="lineno"> 23</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">"\nVector after sorting is: "</span>;</div>
|
||||
<div class="line"><a id="l00024" name="l00024"></a><span class="lineno"> 24</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < n; i++) <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << vect[i] << <span class="stringliteral">" "</span>;</div>
|
||||
<div class="line"><a id="l00025" name="l00025"></a><span class="lineno"> 25</span> </div>
|
||||
<div class="line"><a id="l00026" name="l00026"></a><span class="lineno"> 26</span> <span class="comment">// Reversing the Vector</span></div>
|
||||
<div class="line"><a id="l00027" name="l00027"></a><span class="lineno"> 27</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/reverse.html">std::reverse</a>(vect.begin(), vect.end());</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> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <span class="stringliteral">"\nVector after reversing is: "</span>;</div>
|
||||
<div class="line"><a id="l00030" name="l00030"></a><span class="lineno"> 30</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < 6; i++) <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << vect[i] << <span class="stringliteral">" "</span>;</div>
|
||||
<div class="line"><a id="l00031" name="l00031"></a><span class="lineno"> 31</span> </div>
|
||||
<div class="line"><a id="l00032" name="l00032"></a><span class="lineno"> 32</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">"\nMaximum element of vector is: "</span>;</div>
|
||||
<div class="line"><a id="l00033" name="l00033"></a><span class="lineno"> 33</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << *<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/max_element.html">max_element</a>(vect.begin(), vect.end());</div>
|
||||
<div class="line"><a id="l00034" name="l00034"></a><span class="lineno"> 34</span> </div>
|
||||
<div class="line"><a id="l00035" name="l00035"></a><span class="lineno"> 35</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">"\nMinimum element of vector is: "</span>;</div>
|
||||
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno"> 36</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << *<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/min_element.html">min_element</a>(vect.begin(), vect.end());</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">// Starting the summation from 0</span></div>
|
||||
<div class="line"><a id="l00039" name="l00039"></a><span class="lineno"> 39</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">"\nThe summation of vector elements is: "</span>;</div>
|
||||
<div class="line"><a id="l00040" name="l00040"></a><span class="lineno"> 40</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/accumulate.html">accumulate</a>(vect.begin(), vect.end(), 0);</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="keywordflow">return</span> 0;</div>
|
||||
<div class="line"><a id="l00043" name="l00043"></a><span class="lineno"> 43</span>}</div>
|
||||
<div class="fragment"><div class="line"><span class="lineno"> 11</span> {</div>
|
||||
<div class="line"><span class="lineno"> 12</span> <span class="comment">// Initializing vector with array values</span></div>
|
||||
<div class="line"><span class="lineno"> 13</span> <span class="keywordtype">int</span> arr[] = {10, 20, 5, 23, 42, 15};</div>
|
||||
<div class="line"><span class="lineno"> 14</span> <span class="keywordtype">int</span> n = <span class="keyword">sizeof</span>(arr) / <span class="keyword">sizeof</span>(arr[0]);</div>
|
||||
<div class="line"><span class="lineno"> 15</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector<int></a> vect(arr, arr + n);</div>
|
||||
<div class="line"><span class="lineno"> 16</span> </div>
|
||||
<div class="line"><span class="lineno"> 17</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">"Vector is: "</span>;</div>
|
||||
<div class="line"><span class="lineno"> 18</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < n; i++) <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << vect[i] << <span class="stringliteral">" "</span>;</div>
|
||||
<div class="line"><span class="lineno"> 19</span> </div>
|
||||
<div class="line"><span class="lineno"> 20</span> <span class="comment">// Sorting the Vector in Ascending order</span></div>
|
||||
<div class="line"><span class="lineno"> 21</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/sort.html">std::sort</a>(vect.begin(), vect.end());</div>
|
||||
<div class="line"><span class="lineno"> 22</span> </div>
|
||||
<div class="line"><span class="lineno"> 23</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">"\nVector after sorting is: "</span>;</div>
|
||||
<div class="line"><span class="lineno"> 24</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < n; i++) <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << vect[i] << <span class="stringliteral">" "</span>;</div>
|
||||
<div class="line"><span class="lineno"> 25</span> </div>
|
||||
<div class="line"><span class="lineno"> 26</span> <span class="comment">// Reversing the Vector</span></div>
|
||||
<div class="line"><span class="lineno"> 27</span> <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/reverse.html">std::reverse</a>(vect.begin(), vect.end());</div>
|
||||
<div class="line"><span class="lineno"> 28</span> </div>
|
||||
<div class="line"><span class="lineno"> 29</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">"\nVector after reversing is: "</span>;</div>
|
||||
<div class="line"><span class="lineno"> 30</span> <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < 6; i++) <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << vect[i] << <span class="stringliteral">" "</span>;</div>
|
||||
<div class="line"><span class="lineno"> 31</span> </div>
|
||||
<div class="line"><span class="lineno"> 32</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">"\nMaximum element of vector is: "</span>;</div>
|
||||
<div class="line"><span class="lineno"> 33</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << *<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/max_element.html">max_element</a>(vect.begin(), vect.end());</div>
|
||||
<div class="line"><span class="lineno"> 34</span> </div>
|
||||
<div class="line"><span class="lineno"> 35</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">"\nMinimum element of vector is: "</span>;</div>
|
||||
<div class="line"><span class="lineno"> 36</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << *<a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/min_element.html">min_element</a>(vect.begin(), vect.end());</div>
|
||||
<div class="line"><span class="lineno"> 37</span> </div>
|
||||
<div class="line"><span class="lineno"> 38</span> <span class="comment">// Starting the summation from 0</span></div>
|
||||
<div class="line"><span class="lineno"> 39</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">"\nThe summation of vector elements is: "</span>;</div>
|
||||
<div class="line"><span class="lineno"> 40</span> <a class="code hl_classRef" target="_blank" href="http://en.cppreference.com/w/cpp/io/basic_ostream.html">std::cout</a> << <a class="code hl_functionRef" target="_blank" href="http://en.cppreference.com/w/cpp/algorithm/accumulate.html">accumulate</a>(vect.begin(), vect.end(), 0);</div>
|
||||
<div class="line"><span class="lineno"> 41</span> </div>
|
||||
<div class="line"><span class="lineno"> 42</span> <span class="keywordflow">return</span> 0;</div>
|
||||
<div class="line"><span class="lineno"> 43</span>}</div>
|
||||
<div class="ttc" id="aaccumulate_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/algorithm/accumulate.html">std::accumulate</a></div><div class="ttdeci">T accumulate(T... args)</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="amax_element_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/algorithm/max_element.html">std::max_element</a></div><div class="ttdeci">T max_element(T... args)</div></div>
|
||||
<div class="ttc" id="amin_element_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/algorithm/min_element.html">std::min_element</a></div><div class="ttdeci">T min_element(T... args)</div></div>
|
||||
<div class="ttc" id="areverse_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/algorithm/reverse.html">std::reverse</a></div><div class="ttdeci">T reverse(T... args)</div></div>
|
||||
<div class="ttc" id="asort_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/algorithm/sort.html">std::sort</a></div><div class="ttdeci">T sort(T... args)</div></div>
|
||||
<div class="ttc" id="avector_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector</a></div></div>
|
||||
<div class="ttc" id="avector_html"><div class="ttname"><a href="http://en.cppreference.com/w/cpp/container/vector.html">std::vector< int ></a></div></div>
|
||||
</div><!-- fragment --><div class="dynheader">
|
||||
Here is the call graph for this function:</div>
|
||||
<div class="dyncontent">
|
||||
@@ -188,7 +188,7 @@ Here is the call graph for this function:</div>
|
||||
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
|
||||
<ul>
|
||||
<li class="navelem"><a class="el" href="../../dir_9510827d0b234b3cc54b29892f217477.html">others</a></li><li class="navelem"><a class="el" href="../../d3/d61/vector__important__functions_8cpp.html">vector_important_functions.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.9.2 </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.9.3 </li>
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user