Skip to content

Commit

Permalink
Site updated: 2024-11-25 09:04:18
Browse files Browse the repository at this point in the history
  • Loading branch information
MoonforDream committed Nov 25, 2024
1 parent 9229ef7 commit dcb0f37
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 58 deletions.
8 changes: 4 additions & 4 deletions baidusitemap.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://moonfordream.github.io//posts/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E4%B8%8E%E7%AE%97%E6%B3%95/</loc>
<lastmod>2024-11-25</lastmod>
</url>
<url>
<loc>https://moonfordream.github.io//posts/MoonNet-guide-en/</loc>
<lastmod>2024-11-20</lastmod>
Expand All @@ -20,10 +24,6 @@
<loc>https://moonfordream.github.io//posts/go%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE/</loc>
<lastmod>2024-11-14</lastmod>
</url>
<url>
<loc>https://moonfordream.github.io//posts/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E4%B8%8E%E7%AE%97%E6%B3%95/</loc>
<lastmod>2024-11-09</lastmod>
</url>
<url>
<loc>https://moonfordream.github.io//posts/Reactor%E6%A8%A1%E5%9E%8B/</loc>
<lastmod>2024-10-27</lastmod>
Expand Down
2 changes: 1 addition & 1 deletion local-search.xml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions posts/数据结构与算法/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/MoonforDream/photohouse/hexo/202405191529620.png">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/MoonforDream/photohouse/hexo/202405191529621.png">
<meta property="article:published_time" content="2024-05-19T07:07:29.000Z">
<meta property="article:modified_time" content="2024-11-09T01:41:16.768Z">
<meta property="article:modified_time" content="2024-11-25T01:00:29.951Z">
<meta property="article:author" content="Moon">
<meta property="article:tag" content="后台开发">
<meta property="article:tag" content="C&#x2F;C++">
Expand Down Expand Up @@ -790,7 +790,7 @@ <h3 id="快速排序"><a href="#快速排序" class="headerlink" title="快速

<ul>
<li><p>另一种快速排序,<strong>每一次递归,我们将数组最左端就当作枢纽元</strong>,还是<strong>左端left开始跟right指向的元素跟枢纽元的值比较</strong>,an[left]&lt;枢纽元left++,an[right]&gt;枢纽元right–,<strong>直到找到an[left]&gt;枢纽元,an[right]&lt;枢纽元的时候进行交换an[left]和an[right]<strong>,</strong>直到left&#x3D;&#x3D;right,就将枢纽元(也就是最左端的元素)与left当前所在位置进行交换</strong>,使得枢纽元放在正确的位置,然后在<strong>以left为界限分治。</strong></p>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><code class="hljs c++"><span class="hljs-function"><span class="hljs-type">void</span> <span class="hljs-title">quicksort</span><span class="hljs-params">(<span class="hljs-type">int</span> *an,<span class="hljs-type">int</span> low,<span class="hljs-type">int</span> high)</span></span>&#123;<br> <span class="hljs-type">int</span> left=low,right=high;<br> <span class="hljs-keyword">if</span>(left&lt;high) <span class="hljs-keyword">return</span>;<br> <span class="hljs-type">int</span> temp=an[left]; <span class="hljs-comment">//枢纽元</span><br> <span class="hljs-keyword">while</span>(left!=right)&#123;<br> <span class="hljs-comment">//找寻右边区域小于枢纽元的元素位置</span><br> <span class="hljs-keyword">while</span>(an[right]&gt;=temp&amp;&amp;left&lt;right)&#123;<br> right--;<br> &#125;<br> <span class="hljs-comment">//找寻左边区域大于枢纽元的元素位置</span><br> <span class="hljs-keyword">while</span>(an[left]&lt;=temp&amp;&amp;left&lt;right)&#123;<br> left++;<br> &#125;<br> <span class="hljs-comment">//将找到的进行交换使得左边区域小于枢纽元,右边区域大于枢纽元</span><br> <span class="hljs-keyword">if</span>(left&lt;right)&#123;<br> <span class="hljs-built_in">swap</span>(an[left],an[right]);<br> &#125;<br> &#125;<br> <span class="hljs-comment">//将枢纽元换到正确的中间区域</span><br> <span class="hljs-built_in">swap</span>(an[low],an[left]);<br> <span class="hljs-comment">//以left也就是当前枢纽元所在位置为界限进行分治</span><br> <span class="hljs-built_in">quicksort</span>(an,low,left<span class="hljs-number">-1</span>);<br> <span class="hljs-built_in">quicksort</span>(an,left+<span class="hljs-number">1</span>,high);<br>&#125;<br></code></pre></td></tr></table></figure></li>
<figure class="highlight c++"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><code class="hljs c++"><span class="hljs-function"><span class="hljs-type">void</span> <span class="hljs-title">quicksort</span><span class="hljs-params">(<span class="hljs-type">int</span> *an,<span class="hljs-type">int</span> low,<span class="hljs-type">int</span> high)</span></span>&#123;<br> <span class="hljs-keyword">if</span>(low&gt;=high) <span class="hljs-keyword">return</span>;<br> <span class="hljs-type">int</span> left=low,right=high;<br> <span class="hljs-type">int</span> temp=an[left]; <span class="hljs-comment">//枢纽元</span><br> <span class="hljs-keyword">while</span>(left!=right)&#123;<br> <span class="hljs-comment">//找寻右边区域小于枢纽元的元素位置</span><br> <span class="hljs-keyword">while</span>(an[right]&gt;=temp&amp;&amp;left&lt;right)&#123;<br> right--;<br> &#125;<br> <span class="hljs-comment">//找寻左边区域大于枢纽元的元素位置</span><br> <span class="hljs-keyword">while</span>(an[left]&lt;=temp&amp;&amp;left&lt;right)&#123;<br> left++;<br> &#125;<br> <span class="hljs-comment">//将找到的进行交换使得左边区域小于枢纽元,右边区域大于枢纽元</span><br> <span class="hljs-keyword">if</span>(left&lt;right)&#123;<br> <span class="hljs-built_in">swap</span>(an[left],an[right]);<br> &#125;<br> &#125;<br> <span class="hljs-comment">//将枢纽元换到正确的中间区域</span><br> <span class="hljs-built_in">swap</span>(an[low],an[left]);<br> <span class="hljs-comment">//以left也就是当前枢纽元所在位置为界限进行分治</span><br> <span class="hljs-built_in">quicksort</span>(an,low,left<span class="hljs-number">-1</span>);<br> <span class="hljs-built_in">quicksort</span>(an,left+<span class="hljs-number">1</span>,high);<br>&#125;<br></code></pre></td></tr></table></figure></li>
</ul>
<h3 id="桶式排序"><a href="#桶式排序" class="headerlink" title="桶式排序"></a>桶式排序</h3><p><strong>概念</strong>:</p>
<ul>
Expand Down
Loading

0 comments on commit dcb0f37

Please sign in to comment.