2020-07-05 02:01:07 +08:00
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2022-09-08 08:17:03 +08:00
< html xmlns = "http://www.w3.org/1999/xhtml" lang = "en-US" >
2020-07-05 02:01:07 +08:00
< head >
< meta http-equiv = "Content-Type" content = "text/xhtml;charset=UTF-8" / >
2021-10-26 03:34:27 +08:00
< meta http-equiv = "X-UA-Compatible" content = "IE=11" / >
2023-01-21 05:44:50 +08:00
< meta name = "generator" content = "Doxygen 1.9.6" / >
2020-07-05 02:01:07 +08:00
< meta name = "viewport" content = "width=device-width, initial-scale=1" / >
< title > Algorithms_in_C: Sorting algorithms< / title >
< 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 >
< link href = "../../navtree.css" rel = "stylesheet" type = "text/css" / >
< script type = "text/javascript" src = "../../resize.js" > < / script >
< script type = "text/javascript" src = "../../navtreedata.js" > < / script >
< script type = "text/javascript" src = "../../navtree.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/x-mathjax-config" >
2021-10-26 03:34:27 +08:00
MathJax.Hub.Config({
extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
jax: ["input/TeX","output/HTML-CSS"],
2020-07-05 02:01:07 +08:00
});
< / 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 >
< link href = "../../doxygen.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 >
2022-01-15 04:11:27 +08:00
< tr id = "projectrow" >
< td id = "projectalign" >
2021-10-26 03:34:27 +08:00
< div id = "projectname" > Algorithms_in_C< span id = "projectnumber" >   1.0.0< / span >
2020-07-05 02:01:07 +08:00
< / div >
< div id = "projectbrief" > Set of algorithms implemented in C.< / div >
< / td >
< / tr >
< / tbody >
< / table >
< / div >
<!-- end header part -->
2023-01-21 05:44:50 +08:00
<!-- Generated by Doxygen 1.9.6 -->
2020-07-05 02:01:07 +08:00
< script type = "text/javascript" >
2021-10-26 03:34:27 +08:00
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699& dn=expat.txt MIT */
2022-09-08 08:17:03 +08:00
var searchBox = new SearchBox("searchBox", "../../search/",'.html');
2020-07-05 02:01:07 +08:00
/* @license-end */
< / script >
< script type = "text/javascript" src = "../../menudata.js" > < / script >
< script type = "text/javascript" src = "../../menu.js" > < / script >
< script type = "text/javascript" >
2021-10-26 03:34:27 +08:00
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699& dn=expat.txt MIT */
2020-07-05 02:01:07 +08:00
$(function() {
initMenu('../../',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
2021-10-26 03:34:27 +08:00
/* @license-end */
< / script >
2020-07-05 02:01:07 +08:00
< 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" >
2021-10-26 03:34:27 +08:00
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699& dn=expat.txt MIT */
2020-07-05 02:01:07 +08:00
$(document).ready(function(){initNavTree('d5/d4c/group__sorting.html','../../'); initResizable(); });
/* @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" >
2022-09-08 08:17:03 +08:00
< 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 >
2020-07-05 02:01:07 +08:00
< / div >
< div class = "header" >
< div class = "summary" >
< a href = "#define-members" > Macros< / a > |
< a href = "#func-members" > Functions< / a > < / div >
2021-10-26 03:34:27 +08:00
< div class = "headertitle" > < div class = "title" > Sorting algorithms< / div > < / div >
2020-07-05 02:01:07 +08:00
< / div > <!-- header -->
< div class = "contents" >
< table class = "memberdecls" >
2021-10-26 03:34:27 +08:00
< tr class = "heading" > < td colspan = "2" > < h2 class = "groupheader" > < a id = "define-members" name = "define-members" > < / a >
2020-07-05 02:01:07 +08:00
Macros< / h2 > < / td > < / tr >
2021-10-26 03:34:27 +08:00
< tr class = "memitem:ga4fdb8af29a07ac8f496e49a11bf9f1bd" > < td class = "memItemLeft" align = "right" valign = "top" > < a id = "ga4fdb8af29a07ac8f496e49a11bf9f1bd" name = "ga4fdb8af29a07ac8f496e49a11bf9f1bd" > < / a >
2022-11-25 13:17:20 +08:00
#define  < / td > < td class = "memItemRight" valign = "bottom" > < b > BEAD< / b > (i, j)      beads[i * max + j]< / td > < / tr >
2020-07-05 02:01:07 +08:00
< tr class = "memdesc:ga4fdb8af29a07ac8f496e49a11bf9f1bd" > < td class = "mdescLeft" >   < / td > < td class = "mdescRight" > Create easy access of elements from a 2D matrix stored in memory as a 1D array. < br / > < / td > < / tr >
< tr class = "separator:ga4fdb8af29a07ac8f496e49a11bf9f1bd" > < td class = "memSeparator" colspan = "2" >   < / td > < / tr >
< / table > < table class = "memberdecls" >
2021-10-26 03:34:27 +08:00
< tr class = "heading" > < td colspan = "2" > < h2 class = "groupheader" > < a id = "func-members" name = "func-members" > < / a >
2020-07-05 02:01:07 +08:00
Functions< / h2 > < / td > < / tr >
< tr class = "memitem:gad7ed8cc4603f500d610054680d28b971" > < td class = "memItemLeft" align = "right" valign = "top" > void  < / td > < td class = "memItemRight" valign = "bottom" > < a class = "el" href = "../../d5/d4c/group__sorting.html#gad7ed8cc4603f500d610054680d28b971" > display< / a > (const int *arr, int n)< / td > < / tr >
2023-01-21 05:44:50 +08:00
< tr class = "memdesc:gad7ed8cc4603f500d610054680d28b971" > < td class = "mdescLeft" >   < / td > < td class = "mdescRight" > Displays the array, passed to this method. < br / > < / td > < / tr >
2020-07-05 02:01:07 +08:00
< tr class = "separator:gad7ed8cc4603f500d610054680d28b971" > < td class = "memSeparator" colspan = "2" >   < / td > < / tr >
< tr class = "memitem:ga2fb01e00dedb437a42010f6309e7eba8" > < td class = "memItemLeft" align = "right" valign = "top" > void  < / td > < td class = "memItemRight" valign = "bottom" > < a class = "el" href = "../../d5/d4c/group__sorting.html#ga2fb01e00dedb437a42010f6309e7eba8" > bead_sort< / a > (int *a, size_t len)< / td > < / tr >
2023-01-21 05:44:50 +08:00
< tr class = "memdesc:ga2fb01e00dedb437a42010f6309e7eba8" > < td class = "mdescLeft" >   < / td > < td class = "mdescRight" > This is where the sorting of the array takes place. < br / > < / td > < / tr >
2020-07-05 02:01:07 +08:00
< tr class = "separator:ga2fb01e00dedb437a42010f6309e7eba8" > < td class = "memSeparator" colspan = "2" >   < / td > < / tr >
2020-10-16 21:05:59 +08:00
< tr class = "memitem:ga98666b73777e308fb06a3c489ce25359" > < td class = "memItemLeft" align = "right" valign = "top" > void  < / td > < td class = "memItemRight" valign = "bottom" > < a class = "el" href = "../../d5/d4c/group__sorting.html#ga98666b73777e308fb06a3c489ce25359" > RecursionInsertionSort< / a > (int *arr, int size)< / td > < / tr >
2023-01-21 05:44:50 +08:00
< tr class = "memdesc:ga98666b73777e308fb06a3c489ce25359" > < td class = "mdescLeft" >   < / td > < td class = "mdescRight" > Insertion sort algorithm implements using Recursion. < br / > < / td > < / tr >
2020-10-16 21:05:59 +08:00
< tr class = "separator:ga98666b73777e308fb06a3c489ce25359" > < td class = "memSeparator" colspan = "2" >   < / td > < / tr >
2020-07-05 03:07:10 +08:00
< tr class = "memitem:ga4b9708d87be7a409eff20e5e7e8b43c8" > < td class = "memItemLeft" align = "right" valign = "top" > void  < / td > < td class = "memItemRight" valign = "bottom" > < a class = "el" href = "../../d5/d4c/group__sorting.html#ga4b9708d87be7a409eff20e5e7e8b43c8" > swap< / a > (int *a, int *b)< / td > < / tr >
2023-01-21 05:44:50 +08:00
< tr class = "memdesc:ga4b9708d87be7a409eff20e5e7e8b43c8" > < td class = "mdescLeft" >   < / td > < td class = "mdescRight" > Swap two integer variables. < br / > < / td > < / tr >
2020-07-05 03:07:10 +08:00
< tr class = "separator:ga4b9708d87be7a409eff20e5e7e8b43c8" > < td class = "memSeparator" colspan = "2" >   < / td > < / tr >
< tr class = "memitem:ga8dc3ec66cb3350313fdb34bfd1674729" > < td class = "memItemLeft" align = "right" valign = "top" > void  < / td > < td class = "memItemRight" valign = "bottom" > < a class = "el" href = "../../d5/d4c/group__sorting.html#ga8dc3ec66cb3350313fdb34bfd1674729" > merge< / a > (int *a, int l, int r, int n)< / td > < / tr >
2023-01-21 05:44:50 +08:00
< tr class = "memdesc:ga8dc3ec66cb3350313fdb34bfd1674729" > < td class = "mdescLeft" >   < / td > < td class = "mdescRight" > Perform merge of segments. < br / > < / td > < / tr >
2020-07-05 03:07:10 +08:00
< tr class = "separator:ga8dc3ec66cb3350313fdb34bfd1674729" > < td class = "memSeparator" colspan = "2" >   < / td > < / tr >
< tr class = "memitem:gab99b8a397bdd0bf2903d66c22ba4ba43" > < td class = "memItemLeft" align = "right" valign = "top" > void  < / td > < td class = "memItemRight" valign = "bottom" > < a class = "el" href = "../../d5/d4c/group__sorting.html#gab99b8a397bdd0bf2903d66c22ba4ba43" > merge_sort< / a > (int *a, int n, int l, int r)< / td > < / tr >
2023-01-21 05:44:50 +08:00
< tr class = "memdesc:gab99b8a397bdd0bf2903d66c22ba4ba43" > < td class = "mdescLeft" >   < / td > < td class = "mdescRight" > Merge sort algorithm implementation. < br / > < / td > < / tr >
2020-07-05 03:07:10 +08:00
< tr class = "separator:gab99b8a397bdd0bf2903d66c22ba4ba43" > < td class = "memSeparator" colspan = "2" >   < / td > < / tr >
2021-10-26 03:34:27 +08:00
< tr class = "memitem:gaeccaf61ff47279384d1dba8d869d5c2f" > < td class = "memItemLeft" align = "right" valign = "top" > void  < / td > < td class = "memItemRight" valign = "bottom" > < a class = "el" href = "../../d5/d4c/group__sorting.html#gaeccaf61ff47279384d1dba8d869d5c2f" > show_data< / a > (int *arr, long len)< / td > < / tr >
2023-01-21 05:44:50 +08:00
< tr class = "memdesc:gaeccaf61ff47279384d1dba8d869d5c2f" > < td class = "mdescLeft" >   < / td > < td class = "mdescRight" > Helper function to print array values. < br / > < / td > < / tr >
2020-07-05 02:01:07 +08:00
< tr class = "separator:gaeccaf61ff47279384d1dba8d869d5c2f" > < td class = "memSeparator" colspan = "2" >   < / td > < / tr >
2021-10-26 03:34:27 +08:00
< tr class = "memitem:ga5bc16eaf3ffe6a6ab66780dd445904c0" > < td class = "memItemLeft" align = "right" valign = "top" > void  < / td > < td class = "memItemRight" valign = "bottom" > < a class = "el" href = "../../d5/d4c/group__sorting.html#ga5bc16eaf3ffe6a6ab66780dd445904c0" > shell_sort< / a > (int *array, long < a class = "el" href = "../../df/d27/alaw_8c.html#a05b49c662c073f89e86804f7856622a0" > LEN< / a > )< / td > < / tr >
2023-01-21 05:44:50 +08:00
< tr class = "memdesc:ga5bc16eaf3ffe6a6ab66780dd445904c0" > < td class = "mdescLeft" >   < / td > < td class = "mdescRight" > Shell sort algorithm. < br / > < / td > < / tr >
2020-07-05 02:01:07 +08:00
< tr class = "separator:ga5bc16eaf3ffe6a6ab66780dd445904c0" > < td class = "memSeparator" colspan = "2" >   < / td > < / tr >
< / table >
< a name = "details" id = "details" > < / a > < h2 class = "groupheader" > Detailed Description< / h2 >
< h2 class = "groupheader" > Function Documentation< / h2 >
2021-10-26 03:34:27 +08:00
< a id = "ga2fb01e00dedb437a42010f6309e7eba8" name = "ga2fb01e00dedb437a42010f6309e7eba8" > < / a >
2022-09-08 08:17:03 +08:00
< h2 class = "memtitle" > < span class = "permalink" > < a href = "#ga2fb01e00dedb437a42010f6309e7eba8" > ◆   < / a > < / span > bead_sort()< / h2 >
2020-07-05 02:01:07 +08:00
< div class = "memitem" >
< div class = "memproto" >
< table class = "memname" >
< tr >
< td class = "memname" > void bead_sort < / td >
< td > (< / td >
< td class = "paramtype" > int *  < / td >
< td class = "paramname" > < em > a< / em > , < / td >
< / tr >
< tr >
< td class = "paramkey" > < / td >
< td > < / td >
< td class = "paramtype" > size_t  < / td >
< td class = "paramname" > < em > len< / em >   < / td >
< / tr >
< tr >
< td > < / td >
< td > )< / td >
< td > < / td > < td > < / td >
< / tr >
< / table >
< / div > < div class = "memdoc" >
< p > This is where the sorting of the array takes place. < / p >
< dl class = "params" > < dt > Parameters< / dt > < dd >
< table class = "params" >
< tr > < td class = "paramdir" > [in,out]< / td > < td class = "paramname" > a< / td > < td > array to be sorted < / td > < / tr >
< tr > < td class = "paramdir" > [in]< / td > < td class = "paramname" > len< / td > < td > Array Size < / td > < / tr >
< / table >
< / dd >
< / dl >
2022-01-15 04:11:27 +08:00
< div class = "fragment" > < div class = "line" > < span class = "lineno" > 38< / span > {< / div >
2022-11-25 13:17:20 +08:00
< div class = "line" > < span class = "lineno" > 39< / span > < span class = "keywordtype" > int< / span > i, j, max, sum;< / div >
2022-01-15 04:11:27 +08:00
< div class = "line" > < span class = "lineno" > 40< / span > < span class = "keywordtype" > unsigned< / span > < span class = "keywordtype" > char< / span > *beads;< / div >
< div class = "line" > < span class = "lineno" > 41< / span > < / div >
2022-11-25 13:17:20 +08:00
< div class = "line" > < span class = "lineno" > 42< / span > < span class = "keywordflow" > for< / span > (i = 1, max = a[0]; i < len; i++)< / div >
< div class = "line" > < span class = "lineno" > 43< / span > < span class = "keywordflow" > if< / span > (a[i] > max)< / div >
< div class = "line" > < span class = "lineno" > 44< / span > max = a[i];< / div >
2022-01-15 04:11:27 +08:00
< div class = "line" > < span class = "lineno" > 45< / span > < / div >
2022-11-25 13:17:20 +08:00
< div class = "line" > < span class = "lineno" > 46< / span > beads = < a class = "code hl_define" href = "../../d2/ddd/malloc__dbg_8h.html#afdddaa949a93c1ef559a638e98f9c21b" > calloc< / a > (1, max * len);< / div >
2022-01-15 04:11:27 +08:00
< div class = "line" > < span class = "lineno" > 47< / span > < / div >
< div class = "line" > < span class = "lineno" > 48< / span > < span class = "comment" > /* mark the beads */< / span > < / div >
< div class = "line" > < span class = "lineno" > 49< / span > < span class = "keywordflow" > for< / span > (i = 0; i < len; i++)< / div >
< div class = "line" > < span class = "lineno" > 50< / span > < span class = "keywordflow" > for< / span > (j = 0; j < a[i]; j++) < a class = "code hl_define" href = "../../d5/d4c/group__sorting.html#ga4fdb8af29a07ac8f496e49a11bf9f1bd" > BEAD< / a > (i, j) = 1;< / div >
< div class = "line" > < span class = "lineno" > 51< / span > < / div >
2022-11-25 13:17:20 +08:00
< div class = "line" > < span class = "lineno" > 52< / span > < span class = "keywordflow" > for< / span > (j = 0; j < max; j++)< / div >
2022-01-15 04:11:27 +08:00
< div class = "line" > < span class = "lineno" > 53< / span > {< / div >
< div class = "line" > < span class = "lineno" > 54< / span > < span class = "comment" > /* count how many beads are on each post */< / span > < / div >
< div class = "line" > < span class = "lineno" > 55< / span > < span class = "keywordflow" > for< / span > (sum = i = 0; i < len; i++)< / div >
< div class = "line" > < span class = "lineno" > 56< / span > {< / div >
< div class = "line" > < span class = "lineno" > 57< / span > sum += < a class = "code hl_define" href = "../../d5/d4c/group__sorting.html#ga4fdb8af29a07ac8f496e49a11bf9f1bd" > BEAD< / a > (i, j);< / div >
< div class = "line" > < span class = "lineno" > 58< / span > < a class = "code hl_define" href = "../../d5/d4c/group__sorting.html#ga4fdb8af29a07ac8f496e49a11bf9f1bd" > BEAD< / a > (i, j) = 0;< / div >
< div class = "line" > < span class = "lineno" > 59< / span > }< / div >
< div class = "line" > < span class = "lineno" > 60< / span > < span class = "comment" > /* mark bottom sum beads */< / span > < / div >
< div class = "line" > < span class = "lineno" > 61< / span > < span class = "keywordflow" > for< / span > (i = len - sum; i < len; i++) < a class = "code hl_define" href = "../../d5/d4c/group__sorting.html#ga4fdb8af29a07ac8f496e49a11bf9f1bd" > BEAD< / a > (i, j) = 1;< / div >
< div class = "line" > < span class = "lineno" > 62< / span > }< / div >
< div class = "line" > < span class = "lineno" > 63< / span > < / div >
< div class = "line" > < span class = "lineno" > 64< / span > < span class = "keywordflow" > for< / span > (i = 0; i < len; i++)< / div >
< div class = "line" > < span class = "lineno" > 65< / span > {< / div >
2022-11-25 13:17:20 +08:00
< div class = "line" > < span class = "lineno" > 66< / span > < span class = "keywordflow" > for< / span > (j = 0; j < max & & < a class = "code hl_define" href = "../../d5/d4c/group__sorting.html#ga4fdb8af29a07ac8f496e49a11bf9f1bd" > BEAD< / a > (i, j); j++)< / div >
2022-01-15 04:11:27 +08:00
< div class = "line" > < span class = "lineno" > 67< / span > ;< / div >
< div class = "line" > < span class = "lineno" > 68< / span > a[i] = j;< / div >
< div class = "line" > < span class = "lineno" > 69< / span > }< / div >
< div class = "line" > < span class = "lineno" > 70< / span > < a class = "code hl_define" href = "../../d2/ddd/malloc__dbg_8h.html#a9cc854374299a1dd933bf62029761768" > free< / a > (beads);< / div >
< div class = "line" > < span class = "lineno" > 71< / span > }< / div >
2021-02-06 03:52:57 +08:00
< div class = "ttc" id = "agroup__sorting_html_ga4fdb8af29a07ac8f496e49a11bf9f1bd" > < div class = "ttname" > < a href = "../../d5/d4c/group__sorting.html#ga4fdb8af29a07ac8f496e49a11bf9f1bd" > BEAD< / a > < / div > < div class = "ttdeci" > #define BEAD(i, j)< / div > < div class = "ttdoc" > Create easy access of elements from a 2D matrix stored in memory as a 1D array.< / div > < div class = "ttdef" > < b > Definition:< / b > bead_sort.c:16< / div > < / div >
2021-02-18 06:41:16 +08:00
< div class = "ttc" id = "amalloc__dbg_8h_html_a9cc854374299a1dd933bf62029761768" > < div class = "ttname" > < a href = "../../d2/ddd/malloc__dbg_8h.html#a9cc854374299a1dd933bf62029761768" > free< / a > < / div > < div class = "ttdeci" > #define free(ptr)< / div > < div class = "ttdoc" > This macro replace the standard free function with free_dbg.< / div > < div class = "ttdef" > < b > Definition:< / b > malloc_dbg.h:26< / div > < / div >
< div class = "ttc" id = "amalloc__dbg_8h_html_afdddaa949a93c1ef559a638e98f9c21b" > < div class = "ttname" > < a href = "../../d2/ddd/malloc__dbg_8h.html#afdddaa949a93c1ef559a638e98f9c21b" > calloc< / a > < / div > < div class = "ttdeci" > #define calloc(elemCount, elemSize)< / div > < div class = "ttdoc" > This macro replace the standard calloc function with calloc_dbg.< / div > < div class = "ttdef" > < b > Definition:< / b > malloc_dbg.h:22< / div > < / div >
2020-07-05 02:01:07 +08:00
< / div > <!-- fragment -->
< / div >
< / div >
2021-10-26 03:34:27 +08:00
< a id = "gad7ed8cc4603f500d610054680d28b971" name = "gad7ed8cc4603f500d610054680d28b971" > < / a >
2022-09-08 08:17:03 +08:00
< h2 class = "memtitle" > < span class = "permalink" > < a href = "#gad7ed8cc4603f500d610054680d28b971" > ◆   < / a > < / span > display()< / h2 >
2020-07-05 02:01:07 +08:00
< div class = "memitem" >
< div class = "memproto" >
< table class = "memname" >
< tr >
< td class = "memname" > void display < / td >
< td > (< / td >
< td class = "paramtype" > const int *  < / td >
< td class = "paramname" > < em > arr< / em > , < / td >
< / tr >
< tr >
< td class = "paramkey" > < / td >
< td > < / td >
< td class = "paramtype" > int  < / td >
< td class = "paramname" > < em > n< / em >   < / td >
< / tr >
< tr >
< td > < / td >
< td > )< / td >
< td > < / td > < td > < / td >
< / tr >
< / table >
< / div > < div class = "memdoc" >
< p > Displays the array, passed to this method. < / p >
< dl class = "params" > < dt > Parameters< / dt > < dd >
< table class = "params" >
< tr > < td class = "paramdir" > [in]< / td > < td class = "paramname" > arr< / td > < td > array to display < / td > < / tr >
< tr > < td class = "paramdir" > [in]< / td > < td class = "paramname" > n< / td > < td > number of elements in the array < / td > < / tr >
< / table >
< / dd >
< / dl >
2022-01-15 04:11:27 +08:00
< div class = "fragment" > < div class = "line" > < span class = "lineno" > 24< / span > {< / div >
< div class = "line" > < span class = "lineno" > 25< / span > < span class = "keywordflow" > for< / span > (< span class = "keywordtype" > int< / span > i = 0; i < n; i++)< / div >
< div class = "line" > < span class = "lineno" > 26< / span > {< / div >
< div class = "line" > < span class = "lineno" > 27< / span > printf(< span class = "stringliteral" > " %d " < / span > , arr[i]);< / div >
< div class = "line" > < span class = "lineno" > 28< / span > }< / div >
< div class = "line" > < span class = "lineno" > 29< / span > < / div >
< div class = "line" > < span class = "lineno" > 30< / span > printf(< span class = "stringliteral" > " \n" < / span > );< / div >
< div class = "line" > < span class = "lineno" > 31< / span > }< / div >
2020-07-05 02:01:07 +08:00
< / div > <!-- fragment -->
2020-07-05 03:07:10 +08:00
< / div >
< / div >
2021-10-26 03:34:27 +08:00
< a id = "ga8dc3ec66cb3350313fdb34bfd1674729" name = "ga8dc3ec66cb3350313fdb34bfd1674729" > < / a >
2022-09-08 08:17:03 +08:00
< h2 class = "memtitle" > < span class = "permalink" > < a href = "#ga8dc3ec66cb3350313fdb34bfd1674729" > ◆   < / a > < / span > merge()< / h2 >
2020-07-05 03:07:10 +08:00
< div class = "memitem" >
< div class = "memproto" >
< table class = "memname" >
< tr >
< td class = "memname" > void merge < / td >
< td > (< / td >
< td class = "paramtype" > int *  < / td >
< td class = "paramname" > < em > a< / em > , < / td >
< / tr >
< tr >
< td class = "paramkey" > < / td >
< td > < / td >
< td class = "paramtype" > int  < / td >
< td class = "paramname" > < em > l< / em > , < / td >
< / tr >
< tr >
< td class = "paramkey" > < / td >
< td > < / td >
< td class = "paramtype" > int  < / td >
< td class = "paramname" > < em > r< / em > , < / td >
< / tr >
< tr >
< td class = "paramkey" > < / td >
< td > < / td >
< td class = "paramtype" > int  < / td >
< td class = "paramname" > < em > n< / em >   < / td >
< / tr >
< tr >
< td > < / td >
< td > )< / td >
< td > < / td > < td > < / td >
< / tr >
< / table >
< / div > < div class = "memdoc" >
< p > Perform merge of segments. < / p >
< dl class = "params" > < dt > Parameters< / dt > < dd >
< table class = "params" >
< tr > < td class = "paramname" > a< / td > < td > array to sort < / td > < / tr >
< tr > < td class = "paramname" > l< / td > < td > left index for merge < / td > < / tr >
< tr > < td class = "paramname" > r< / td > < td > right index for merge < / td > < / tr >
< tr > < td class = "paramname" > n< / td > < td > total number of elements in the array < / td > < / tr >
< / table >
< / dd >
< / dl >
2022-01-15 04:11:27 +08:00
< div class = "fragment" > < div class = "line" > < span class = "lineno" > 34< / span > {< / div >
< div class = "line" > < span class = "lineno" > 35< / span > < span class = "keywordtype" > int< / span > *b = (< span class = "keywordtype" > int< / span > *)< a class = "code hl_define" href = "../../d2/ddd/malloc__dbg_8h.html#a725f50ecaf1959d96de79b36b4788fee" > malloc< / a > (n * < span class = "keyword" > sizeof< / span > (< span class = "keywordtype" > int< / span > )); < span class = "comment" > /* dynamic memory must be freed */< / span > < / div >
< div class = "line" > < span class = "lineno" > 36< / span > < span class = "keywordtype" > int< / span > c = l;< / div >
< div class = "line" > < span class = "lineno" > 37< / span > < span class = "keywordtype" > int< / span > p1, p2;< / div >
< div class = "line" > < span class = "lineno" > 38< / span > p1 = l;< / div >
< div class = "line" > < span class = "lineno" > 39< / span > p2 = ((l + r) / 2) + 1;< / div >
< div class = "line" > < span class = "lineno" > 40< / span > < span class = "keywordflow" > while< / span > ((p1 < ((l + r) / 2) + 1) & & (p2 < r + 1))< / div >
< div class = "line" > < span class = "lineno" > 41< / span > {< / div >
< div class = "line" > < span class = "lineno" > 42< / span > < span class = "keywordflow" > if< / span > (a[p1] < = a[p2])< / div >
< div class = "line" > < span class = "lineno" > 43< / span > {< / div >
< div class = "line" > < span class = "lineno" > 44< / span > b[c++] = a[p1];< / div >
< div class = "line" > < span class = "lineno" > 45< / span > p1++;< / div >
< div class = "line" > < span class = "lineno" > 46< / span > }< / div >
< div class = "line" > < span class = "lineno" > 47< / span > < span class = "keywordflow" > else< / span > < / div >
< div class = "line" > < span class = "lineno" > 48< / span > {< / div >
< div class = "line" > < span class = "lineno" > 49< / span > b[c++] = a[p2];< / div >
< div class = "line" > < span class = "lineno" > 50< / span > p2++;< / div >
< div class = "line" > < span class = "lineno" > 51< / span > }< / div >
< div class = "line" > < span class = "lineno" > 52< / span > }< / div >
< div class = "line" > < span class = "lineno" > 53< / span > < / div >
< div class = "line" > < span class = "lineno" > 54< / span > < span class = "keywordflow" > if< / span > (p2 == r + 1)< / div >
< div class = "line" > < span class = "lineno" > 55< / span > {< / div >
< div class = "line" > < span class = "lineno" > 56< / span > < span class = "keywordflow" > while< / span > ((p1 < ((l + r) / 2) + 1))< / div >
< div class = "line" > < span class = "lineno" > 57< / span > {< / div >
< div class = "line" > < span class = "lineno" > 58< / span > b[c++] = a[p1];< / div >
< div class = "line" > < span class = "lineno" > 59< / span > p1++;< / div >
< div class = "line" > < span class = "lineno" > 60< / span > }< / div >
< div class = "line" > < span class = "lineno" > 61< / span > }< / div >
< div class = "line" > < span class = "lineno" > 62< / span > < span class = "keywordflow" > else< / span > < / div >
< div class = "line" > < span class = "lineno" > 63< / span > {< / div >
< div class = "line" > < span class = "lineno" > 64< / span > < span class = "keywordflow" > while< / span > ((p2 < r + 1))< / div >
< div class = "line" > < span class = "lineno" > 65< / span > {< / div >
< div class = "line" > < span class = "lineno" > 66< / span > b[c++] = a[p2];< / div >
< div class = "line" > < span class = "lineno" > 67< / span > p2++;< / div >
< div class = "line" > < span class = "lineno" > 68< / span > }< / div >
< div class = "line" > < span class = "lineno" > 69< / span > }< / div >
< div class = "line" > < span class = "lineno" > 70< / span > < / div >
< div class = "line" > < span class = "lineno" > 71< / span > < span class = "keywordflow" > for< / span > (c = l; c < r + 1; c++) a[c] = b[c];< / div >
< div class = "line" > < span class = "lineno" > 72< / span > < / div >
< div class = "line" > < span class = "lineno" > 73< / span > < a class = "code hl_define" href = "../../d2/ddd/malloc__dbg_8h.html#a9cc854374299a1dd933bf62029761768" > free< / a > (b);< / div >
< div class = "line" > < span class = "lineno" > 74< / span > }< / div >
2021-02-18 06:41:16 +08:00
< div class = "ttc" id = "amalloc__dbg_8h_html_a725f50ecaf1959d96de79b36b4788fee" > < div class = "ttname" > < a href = "../../d2/ddd/malloc__dbg_8h.html#a725f50ecaf1959d96de79b36b4788fee" > malloc< / a > < / div > < div class = "ttdeci" > #define malloc(bytes)< / div > < div class = "ttdoc" > This macro replace the standard malloc function with malloc_dbg.< / div > < div class = "ttdef" > < b > Definition:< / b > malloc_dbg.h:18< / div > < / div >
2020-07-05 03:07:10 +08:00
< / div > <!-- fragment -->
< / div >
< / div >
2021-10-26 03:34:27 +08:00
< a id = "gab99b8a397bdd0bf2903d66c22ba4ba43" name = "gab99b8a397bdd0bf2903d66c22ba4ba43" > < / a >
2022-09-08 08:17:03 +08:00
< h2 class = "memtitle" > < span class = "permalink" > < a href = "#gab99b8a397bdd0bf2903d66c22ba4ba43" > ◆   < / a > < / span > merge_sort()< / h2 >
2020-07-05 03:07:10 +08:00
< div class = "memitem" >
< div class = "memproto" >
< table class = "memname" >
< tr >
< td class = "memname" > void merge_sort < / td >
< td > (< / td >
< td class = "paramtype" > int *  < / td >
< td class = "paramname" > < em > a< / em > , < / td >
< / tr >
< tr >
< td class = "paramkey" > < / td >
< td > < / td >
< td class = "paramtype" > int  < / td >
< td class = "paramname" > < em > n< / em > , < / td >
< / tr >
< tr >
< td class = "paramkey" > < / td >
< td > < / td >
< td class = "paramtype" > int  < / td >
< td class = "paramname" > < em > l< / em > , < / td >
< / tr >
< tr >
< td class = "paramkey" > < / td >
< td > < / td >
< td class = "paramtype" > int  < / td >
< td class = "paramname" > < em > r< / em >   < / td >
< / tr >
< tr >
< td > < / td >
< td > )< / td >
< td > < / td > < td > < / td >
< / tr >
< / table >
< / div > < div class = "memdoc" >
< p > Merge sort algorithm implementation. < / p >
< dl class = "params" > < dt > Parameters< / dt > < dd >
< table class = "params" >
< tr > < td class = "paramname" > a< / td > < td > array to sort < / td > < / tr >
< tr > < td class = "paramname" > n< / td > < td > number of elements in the array < / td > < / tr >
< tr > < td class = "paramname" > l< / td > < td > index to sort from < / td > < / tr >
< tr > < td class = "paramname" > r< / td > < td > index to sort till < / td > < / tr >
< / table >
< / dd >
< / dl >
2022-01-15 04:11:27 +08:00
< div class = "fragment" > < div class = "line" > < span class = "lineno" > 83< / span > {< / div >
< div class = "line" > < span class = "lineno" > 84< / span > < span class = "keywordflow" > if< / span > (r - l == 1)< / div >
< div class = "line" > < span class = "lineno" > 85< / span > {< / div >
< div class = "line" > < span class = "lineno" > 86< / span > < span class = "keywordflow" > if< / span > (a[l] > a[r])< / div >
2022-09-08 08:17:03 +08:00
< div class = "line" > < span class = "lineno" > 87< / span > swap(& a[l], & a[r]);< / div >
2022-01-15 04:11:27 +08:00
< div class = "line" > < span class = "lineno" > 88< / span > }< / div >
< div class = "line" > < span class = "lineno" > 89< / span > < span class = "keywordflow" > else< / span > < span class = "keywordflow" > if< / span > (l != r)< / div >
< div class = "line" > < span class = "lineno" > 90< / span > {< / div >
< div class = "line" > < span class = "lineno" > 91< / span > < a class = "code hl_function" href = "../../d5/d4c/group__sorting.html#gab99b8a397bdd0bf2903d66c22ba4ba43" > merge_sort< / a > (a, n, l, (l + r) / 2);< / div >
< div class = "line" > < span class = "lineno" > 92< / span > < a class = "code hl_function" href = "../../d5/d4c/group__sorting.html#gab99b8a397bdd0bf2903d66c22ba4ba43" > merge_sort< / a > (a, n, ((l + r) / 2) + 1, r);< / div >
2022-09-08 08:17:03 +08:00
< div class = "line" > < span class = "lineno" > 93< / span > merge(a, l, r, n);< / div >
2022-01-15 04:11:27 +08:00
< div class = "line" > < span class = "lineno" > 94< / span > }< / div >
< div class = "line" > < span class = "lineno" > 95< / span > < / div >
< div class = "line" > < span class = "lineno" > 96< / span > < span class = "comment" > /* no change if l == r */< / span > < / div >
< div class = "line" > < span class = "lineno" > 97< / span > }< / div >
2021-02-06 03:52:57 +08:00
< div class = "ttc" id = "agroup__sorting_html_gab99b8a397bdd0bf2903d66c22ba4ba43" > < div class = "ttname" > < a href = "../../d5/d4c/group__sorting.html#gab99b8a397bdd0bf2903d66c22ba4ba43" > merge_sort< / a > < / div > < div class = "ttdeci" > void merge_sort(int *a, int n, int l, int r)< / div > < div class = "ttdoc" > Merge sort algorithm implementation.< / div > < div class = "ttdef" > < b > Definition:< / b > merge_sort.c:82< / div > < / div >
2020-07-05 03:07:10 +08:00
< / div > <!-- fragment --> < div class = "dynheader" >
Here is the call graph for this function:< / div >
< div class = "dyncontent" >
2022-09-08 08:17:03 +08:00
< div class = "center" > < iframe scrolling = "no" frameborder = "0" src = "../../d5/d4c/group__sorting_gab99b8a397bdd0bf2903d66c22ba4ba43_cgraph.svg" width = "98" height = "60" > < p > < b > This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.< / b > < / p > < / iframe >
2020-07-05 03:07:10 +08:00
< / div >
< / div >
2020-10-16 21:05:59 +08:00
< / div >
< / div >
2021-10-26 03:34:27 +08:00
< a id = "ga98666b73777e308fb06a3c489ce25359" name = "ga98666b73777e308fb06a3c489ce25359" > < / a >
2022-09-08 08:17:03 +08:00
< h2 class = "memtitle" > < span class = "permalink" > < a href = "#ga98666b73777e308fb06a3c489ce25359" > ◆   < / a > < / span > RecursionInsertionSort()< / h2 >
2020-10-16 21:05:59 +08:00
< div class = "memitem" >
< div class = "memproto" >
< table class = "memname" >
< tr >
< td class = "memname" > void RecursionInsertionSort < / td >
< td > (< / td >
< td class = "paramtype" > int *  < / td >
< td class = "paramname" > < em > arr< / em > , < / td >
< / tr >
< tr >
< td class = "paramkey" > < / td >
< td > < / td >
< td class = "paramtype" > int  < / td >
< td class = "paramname" > < em > size< / em >   < / td >
< / tr >
< tr >
< td > < / td >
< td > )< / td >
< td > < / td > < td > < / td >
< / tr >
< / table >
< / div > < div class = "memdoc" >
< p > Insertion sort algorithm implements using Recursion. < / p >
< dl class = "params" > < dt > Parameters< / dt > < dd >
< table class = "params" >
< tr > < td class = "paramname" > arr< / td > < td > array to be sorted < / td > < / tr >
< tr > < td class = "paramname" > size< / td > < td > size of array < / td > < / tr >
< / table >
< / dd >
< / dl >
2022-01-15 04:11:27 +08:00
< div class = "fragment" > < div class = "line" > < span class = "lineno" > 21< / span > {< / div >
< div class = "line" > < span class = "lineno" > 22< / span > < span class = "keywordflow" > if< / span > (size < = 0)< / div >
< div class = "line" > < span class = "lineno" > 23< / span > {< / div >
< div class = "line" > < span class = "lineno" > 24< / span > < span class = "keywordflow" > return< / span > ;< / div >
< div class = "line" > < span class = "lineno" > 25< / span > }< / div >
< div class = "line" > < span class = "lineno" > 26< / span > < / div >
< div class = "line" > < span class = "lineno" > 27< / span > < span class = "comment" > // marking recursive call to reach starting element< / span > < / div >
< div class = "line" > < span class = "lineno" > 28< / span > < a class = "code hl_function" href = "../../d5/d4c/group__sorting.html#ga98666b73777e308fb06a3c489ce25359" > RecursionInsertionSort< / a > (arr,size-1);< / div >
< div class = "line" > < span class = "lineno" > 29< / span > < / div >
< div class = "line" > < span class = "lineno" > 30< / span > < span class = "keywordtype" > int< / span > key = arr[size-1];< / div >
< div class = "line" > < span class = "lineno" > 31< / span > < span class = "keywordtype" > int< / span > j = size-2;< / div >
< div class = "line" > < span class = "lineno" > 32< / span > < span class = "comment" > // swapping logic for insertion sort< / span > < / div >
< div class = "line" > < span class = "lineno" > 33< / span > < span class = "keywordflow" > while< / span > (j > = 0 & & arr[j] > key)< / div >
< div class = "line" > < span class = "lineno" > 34< / span > {< / div >
< div class = "line" > < span class = "lineno" > 35< / span > arr[j+1] = arr[j];< / div >
< div class = "line" > < span class = "lineno" > 36< / span > j--;< / div >
< div class = "line" > < span class = "lineno" > 37< / span > }< / div >
< div class = "line" > < span class = "lineno" > 38< / span > arr[j+1] = key;< / div >
< div class = "line" > < span class = "lineno" > 39< / span > }< / div >
2021-02-06 03:52:57 +08:00
< div class = "ttc" id = "agroup__sorting_html_ga98666b73777e308fb06a3c489ce25359" > < div class = "ttname" > < a href = "../../d5/d4c/group__sorting.html#ga98666b73777e308fb06a3c489ce25359" > RecursionInsertionSort< / a > < / div > < div class = "ttdeci" > void RecursionInsertionSort(int *arr, int size)< / div > < div class = "ttdoc" > Insertion sort algorithm implements using Recursion.< / div > < div class = "ttdef" > < b > Definition:< / b > insertion_sort_recursive.c:20< / div > < / div >
2021-10-26 03:34:27 +08:00
< / div > <!-- fragment --> < div class = "dynheader" >
Here is the call graph for this function:< / div >
< div class = "dyncontent" >
2022-09-08 08:17:03 +08:00
< div class = "center" > < iframe scrolling = "no" frameborder = "0" src = "../../d5/d4c/group__sorting_ga98666b73777e308fb06a3c489ce25359_cgraph.svg" width = "166" height = "60" > < p > < b > This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.< / b > < / p > < / iframe >
2021-10-26 03:34:27 +08:00
< / div >
< / div >
2020-07-05 02:01:07 +08:00
< / div >
< / div >
2021-10-26 03:34:27 +08:00
< a id = "ga5bc16eaf3ffe6a6ab66780dd445904c0" name = "ga5bc16eaf3ffe6a6ab66780dd445904c0" > < / a >
2022-09-08 08:17:03 +08:00
< h2 class = "memtitle" > < span class = "permalink" > < a href = "#ga5bc16eaf3ffe6a6ab66780dd445904c0" > ◆   < / a > < / span > shell_sort()< / h2 >
2020-07-05 02:01:07 +08:00
< div class = "memitem" >
< div class = "memproto" >
< table class = "memname" >
< tr >
< td class = "memname" > void shell_sort < / td >
< td > (< / td >
< td class = "paramtype" > int *  < / td >
< td class = "paramname" > < em > array< / em > , < / td >
< / tr >
< tr >
< td class = "paramkey" > < / td >
< td > < / td >
< td class = "paramtype" > long  < / td >
< td class = "paramname" > < em > LEN< / em >   < / td >
< / tr >
< tr >
< td > < / td >
< td > )< / td >
< td > < / td > < td > < / td >
< / tr >
< / table >
< / div > < div class = "memdoc" >
< p > Shell sort algorithm. < / p >
2023-01-21 05:44:50 +08:00
< p > < br / >
2020-07-05 02:01:07 +08:00
Optimized algorithm - takes half the time as other < / p > < dl class = "params" > < dt > Parameters< / dt > < dd >
< table class = "params" >
< tr > < td class = "paramdir" > [in,out]< / td > < td class = "paramname" > array< / td > < td > array to sort < / td > < / tr >
< tr > < td class = "paramdir" > [in]< / td > < td class = "paramname" > LEN< / td > < td > length of the array < / td > < / tr >
< / table >
< / dd >
< / dl >
2022-01-15 04:11:27 +08:00
< div class = "fragment" > < div class = "line" > < span class = "lineno" > 42< / span > {< / div >
< div class = "line" > < span class = "lineno" > 43< / span > < span class = "keyword" > const< / span > < span class = "keywordtype" > int< / span > gaps[] = {701, 301, 132, 57, 23, 10, 4, 1};< / div >
< div class = "line" > < span class = "lineno" > 44< / span > < span class = "keyword" > const< / span > < span class = "keywordtype" > int< / span > gap_len = 8;< / div >
< div class = "line" > < span class = "lineno" > 45< / span > < span class = "keywordtype" > long< / span > i, j, g;< / div >
< div class = "line" > < span class = "lineno" > 46< / span > < / div >
< div class = "line" > < span class = "lineno" > 47< / span > < span class = "keywordflow" > for< / span > (g = 0; g < gap_len; g++)< / div >
< div class = "line" > < span class = "lineno" > 48< / span > { < span class = "comment" > // for each gap< / span > < / div >
< div class = "line" > < span class = "lineno" > 49< / span > < span class = "keywordtype" > int< / span > gap = gaps[g];< / div >
< div class = "line" > < span class = "lineno" > 50< / span > < span class = "keywordflow" > for< / span > (i = gap; i < < a class = "code hl_define" href = "../../df/d27/alaw_8c.html#a05b49c662c073f89e86804f7856622a0" > LEN< / a > ; i++)< / div >
< div class = "line" > < span class = "lineno" > 51< / span > { < span class = "comment" > // from gap position to the end< / span > < / div >
< div class = "line" > < span class = "lineno" > 52< / span > < span class = "keywordtype" > int< / span > tmp = array[i];< / div >
< div class = "line" > < span class = "lineno" > 53< / span > < / div >
< div class = "line" > < span class = "lineno" > 54< / span > < span class = "keywordflow" > for< / span > (j = i; j > = gap & & (array[j - gap] - tmp) > 0; j -= gap)< / div >
< div class = "line" > < span class = "lineno" > 55< / span > array[j] = array[j - gap];< / div >
< div class = "line" > < span class = "lineno" > 56< / span > array[j] = tmp;< / div >
< div class = "line" > < span class = "lineno" > 57< / span > }< / div >
< div class = "line" > < span class = "lineno" > 58< / span > }< / div >
< div class = "line" > < span class = "lineno" > 59< / span > < span class = "preprocessor" > #ifdef DEBUG< / span > < / div >
< div class = "line" > < span class = "lineno" > 60< / span > < span class = "keywordflow" > for< / span > (i = 0; i < < a class = "code hl_define" href = "../../df/d27/alaw_8c.html#a05b49c662c073f89e86804f7856622a0" > LEN< / a > ; i++) printf(< span class = "stringliteral" > " %s\t" < / span > , < a class = "code hl_struct" href = "../../df/dea/structdata.html" > data< / a > [i]);< / div >
< div class = "line" > < span class = "lineno" > 61< / span > < span class = "preprocessor" > #endif< / span > < / div >
< div class = "line" > < span class = "lineno" > 62< / span > }< / div >
2021-10-26 03:34:27 +08:00
< div class = "ttc" id = "aalaw_8c_html_a05b49c662c073f89e86804f7856622a0" > < div class = "ttname" > < a href = "../../df/d27/alaw_8c.html#a05b49c662c073f89e86804f7856622a0" > LEN< / a > < / div > < div class = "ttdeci" > #define LEN< / div > < div class = "ttdoc" > Linear input code | Compressed code | Linear output code ---------------—+--------------—+-----------...< / div > < div class = "ttdef" > < b > Definition:< / b > alaw.c:28< / div > < / div >
2021-02-06 03:52:57 +08:00
< div class = "ttc" id = "astructdata_html" > < div class = "ttname" > < a href = "../../df/dea/structdata.html" > data< / a > < / div > < div class = "ttdef" > < b > Definition:< / b > prime_factoriziation.c:25< / div > < / div >
2020-07-05 02:01:07 +08:00
< / div > <!-- fragment -->
< / div >
< / div >
2021-10-26 03:34:27 +08:00
< a id = "gaeccaf61ff47279384d1dba8d869d5c2f" name = "gaeccaf61ff47279384d1dba8d869d5c2f" > < / a >
2022-09-08 08:17:03 +08:00
< h2 class = "memtitle" > < span class = "permalink" > < a href = "#gaeccaf61ff47279384d1dba8d869d5c2f" > ◆   < / a > < / span > show_data()< / h2 >
2021-10-26 03:34:27 +08:00
< div class = "memitem" >
< div class = "memproto" >
< table class = "memname" >
< tr >
< td class = "memname" > void show_data < / td >
< td > (< / td >
< td class = "paramtype" > int *  < / td >
< td class = "paramname" > < em > arr< / em > , < / td >
< / tr >
< tr >
< td class = "paramkey" > < / td >
< td > < / td >
< td class = "paramtype" > long  < / td >
< td class = "paramname" > < em > len< / em >   < / td >
< / tr >
< tr >
< td > < / td >
< td > )< / td >
< td > < / td > < td > < / td >
< / tr >
< / table >
< / div > < div class = "memdoc" >
< p > Helper function to print array values. < / p >
2022-01-15 04:11:27 +08:00
< div class = "fragment" > < div class = "line" > < span class = "lineno" > 17< / span > {< / div >
< div class = "line" > < span class = "lineno" > 18< / span > < span class = "keywordflow" > for< / span > (< span class = "keywordtype" > long< / span > i = 0; i < len; i++) printf(< span class = "stringliteral" > " %3d " < / span > , arr[i]);< / div >
< div class = "line" > < span class = "lineno" > 19< / span > printf(< span class = "stringliteral" > " \n" < / span > );< / div >
< div class = "line" > < span class = "lineno" > 20< / span > }< / div >
2021-10-26 03:34:27 +08:00
< / div > <!-- fragment -->
< / div >
< / div >
< a id = "ga4b9708d87be7a409eff20e5e7e8b43c8" name = "ga4b9708d87be7a409eff20e5e7e8b43c8" > < / a >
2022-09-08 08:17:03 +08:00
< h2 class = "memtitle" > < span class = "permalink" > < a href = "#ga4b9708d87be7a409eff20e5e7e8b43c8" > ◆   < / a > < / span > swap()< / h2 >
2020-07-05 02:01:07 +08:00
< div class = "memitem" >
< div class = "memproto" >
< table class = "memname" >
< tr >
< td class = "memname" > void swap < / td >
< td > (< / td >
< td class = "paramtype" > int *  < / td >
< td class = "paramname" > < em > a< / em > , < / td >
< / tr >
< tr >
< td class = "paramkey" > < / td >
< td > < / td >
< td class = "paramtype" > int *  < / td >
< td class = "paramname" > < em > b< / em >   < / td >
< / tr >
< tr >
< td > < / td >
< td > )< / td >
< td > < / td > < td > < / td >
< / tr >
< / table >
< / div > < div class = "memdoc" >
2020-07-05 03:07:10 +08:00
< p > Swap two integer variables. < / p >
2023-01-21 05:44:50 +08:00
< p > Function to swap values of two integers.< / p >
2020-07-05 02:01:07 +08:00
< dl class = "params" > < dt > Parameters< / dt > < dd >
< table class = "params" >
2020-07-05 03:07:10 +08:00
< tr > < td class = "paramdir" > [in,out]< / td > < td class = "paramname" > a< / td > < td > pointer to first variable < / td > < / tr >
< tr > < td class = "paramdir" > [in,out]< / td > < td class = "paramname" > b< / td > < td > pointer to second variable< / td > < / tr >
2020-07-05 02:01:07 +08:00
< tr > < td class = "paramdir" > [in,out]< / td > < td class = "paramname" > a< / td > < td > reference to first variable < / td > < / tr >
< tr > < td class = "paramdir" > [in,out]< / td > < td class = "paramname" > b< / td > < td > reference to second variable < / td > < / tr >
< / table >
< / dd >
< / dl >
2022-01-15 04:11:27 +08:00
< div class = "fragment" > < div class = "line" > < span class = "lineno" > 18< / span > {< / div >
< div class = "line" > < span class = "lineno" > 19< / span > < span class = "keywordtype" > int< / span > t;< / div >
< div class = "line" > < span class = "lineno" > 20< / span > t = *a;< / div >
< div class = "line" > < span class = "lineno" > 21< / span > *a = *b;< / div >
< div class = "line" > < span class = "lineno" > 22< / span > *b = t;< / div >
< div class = "line" > < span class = "lineno" > 23< / span > }< / div >
2020-07-05 02:01:07 +08:00
< / div > <!-- fragment -->
< / div >
< / div >
< / div > <!-- contents -->
< / div > <!-- doc - content -->
<!-- start footer part -->
< div id = "nav-path" class = "navpath" > <!-- id is needed for treeview function! -->
< ul >
2023-01-21 05:44:50 +08:00
< 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.6 < / li >
2020-07-05 02:01:07 +08:00
< / ul >
< / div >
< / body >
< / html >