{"id":446,"date":"2020-04-19T12:24:29","date_gmt":"2020-04-19T04:24:29","guid":{"rendered":"https:\/\/www.notown.club\/?p=446"},"modified":"2020-08-23T11:32:18","modified_gmt":"2020-08-23T03:32:18","slug":"%e4%b8%80%e4%ba%9b%e6%8e%92%e5%ba%8f%e7%ae%97%e6%b3%95","status":"publish","type":"post","link":"https:\/\/www.notown.top\/?p=446","title":{"rendered":"\u4e00\u4e9b\u6392\u5e8f\u7b97\u6cd5"},"content":{"rendered":"\n<p>\u5b66\u6570\u636e\u7ed3\u6784\u548c\u7b97\u6cd5\u7684\u65f6\u5019\u63a5\u89e6\u5230\u4e86\u4e0d\u5c11\u6392\u5e8f\u7b97\u6cd5\uff0c\u5728\u8fd9\u91cc\u6574\u7406\u4e00\u4e0b\u3002<br>\u6d89\u53ca\u5230\u7684\u6392\u5e8f\u7b97\u6cd5\u6709<strong>\u5192\u6ce1\u6392\u5e8f\u3001\u9009\u62e9\u6392\u5e8f\u3001\u63d2\u5165\u6392\u5e8f\u3001\u5e0c\u5c14\u6392\u5e8f\u3001\u5f52\u5e76\u6392\u5e8f\u3001\u5feb\u901f\u6392\u5e8f<\/strong><\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>\u4e00\u3001\u66b4\u529b\u6392\u5e8f<\/strong>\uff08\u6211\u4e5f\u4e0d\u77e5\u9053\u53eb\u4ec0\u4e48\uff0c\u611f\u89c9\u5f88\u66b4\u529b\u5c31\u8fd9\u6837\u53eb\u4e86\uff09<\/p>\n\n\n\n<p>\u4e3b\u8981\u601d\u60f3\u662f\uff1a<br>\u5c06\u6570\u7ec4\u7684\u7b2c\u4e00\u4e2a\u6570\u548c\u63a5\u4e0b\u6765\u7684\u6240\u6709\u6570\u6bd4\u8f83\uff0c\u82e5\u8be5\u6570\u5c0f\u4e8e\u7b2c\u4e00\u4e2a\u6570\uff0c\u5219\u4ed6\u4fe9\u4ea4\u6362\u4f4d\u7f6e\uff0c\u7b2c\u4e00\u8f6e\u904d\u5386\u4ea4\u6362\u5b8c\u5c31\u80fd\u627e\u51fa\u6700\u5c0f\u7684\u503c\u653e\u5728\u7b2c\u4e00\u4f4d\uff0c\u7136\u540e\u627e\u6570\u7ec4\u7684\u7b2c\u4e8c\u4e2a\u6570\u548c\u540e\u9762\u7684\u6240\u6709\u6570\u6bd4\u8f83\uff0c\u4e5f\u662f\u4ea4\u6362\u51fa\u5728\u540e\u9762\u7684\u6570\u4e2d\u6700\u5c0f\u7684\uff08\u5728\u6574\u4e2a\u6570\u7ec4\u4e2d\u5c31\u662f\u7b2c\u4e8c\u5c0f\u7684\uff09<br>\u4f9d\u6b21\u7c7b\u63a8\uff0c\u4e00\u76f4\u6392\u5b8c\u6574\u4e2a\u6570\u7ec4<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">void ForceSort(vector&lt;int> &amp;arr)\n {\n     int temp,len=arr.size();\n     for (int i = 0; i &lt; len - 1; ++i)\n     {\n         for (int j = i + 1; j &lt; len; ++j)\n         {\n             if (arr[i] > arr[j])\n             {\n                 temp = arr[j];\n                 arr[j] = arr[i];\n                 arr[i] = temp;\n             }\n         }\n     }\n }<\/pre>\n\n\n\n<p class=\"has-medium-font-size\"><strong>\u4e8c\u3001\u5192\u6ce1\u6392\u5e8f<\/strong><\/p>\n\n\n\n<p>\u4e3b\u8981\u662f\u6bd4\u8f83\u4e24\u4e24\u76f8\u90bb\u7684\u6570\uff0c\u5982\u679c\u662f\u5de6\u8fb9\u6bd4\u53f3\u8fb9\u5927\uff0c\u5219\u4ea4\u6362\uff0c\u5426\u5219\u5c31\u8df3\u8fc7\uff0c\u6bcf\u8fd9\u6837\u4ece\u6570\u7ec4\u7684\u5c3e\u5230\u5934\u4e24\u4e24\u4ea4\u6362\u4e00\u8f6e\uff0c\u5c31\u80fd\u9009\u51fa\u4e00\u4e2a\u6700\u5c0f\u503c\uff0c\u7136\u540e\u4e0b\u4e00\u8f6e\u5c31\u4e0d\u7528\u518d\u7ba1\u8fd9\u4e2a\u6700\u5c0f\u503c\u4e86(++i)<br>\u4e0b\u9762\u8fd8\u4f7f\u7528\u4e86\u4e00\u4e2atag\u4f5c\u4e3a\u6807\u5fd7\u4f4d\uff0c\u5f53\u67d0\u8f6e\u5192\u6ce1\u4ece\u5c3e\u5230\u5934\u90fd\u5df2\u7ecf\u6ca1\u6709\u51fa\u73b0\u8fc7\u4ea4\u6362\uff0c\u5c31\u8bc1\u660e\u5df2\u7ecf\u6392\u5e8f\u597d\u4e86\uff0c\u4e0d\u7528\u518d\u8fdb\u884c\u6bd4\u8f83\u4e86\uff0c\u76f4\u63a5\u9000\u51fa\u5faa\u73af\u3002\u5c31\u662f\u56e0\u4e3a\u4ed6\u80fd\u7528tag\u4f5c\u4e3a\u4e00\u79cd\u4f18\u5316\uff0c\u6240\u4ee5\u5728\u67d0\u4e9b\u4e0d\u5b8c\u5168\u4e71\u5e8f\u7684\u6392\u5e8f\u4efb\u52a1\u4e2d\uff0c\u8981\u6bd4\u4e0a\u9762\u7684\u66b4\u529b\u6392\u5e8f\u8981\u597d<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">void BubbleSort(vector&lt;int>&amp; arr)\n {\n     int temp, len = arr.size();\n     bool tag=true;\n     for (int i = 0; (i &lt; len - 1) &amp;&amp; tag; ++i)\n     {\n         tag = false;\n         for (int j = len - 1; j >= i+1; --j)\/\/\u4ece\u6700\u540e\u9762\u5f00\u59cb\uff0c\u6267\u884c\u5b8c\u4e00\u6b21\u6b64\u5faa\u73af\u5219\u5c06\u6700\u5c0f\u7684\u6570\u6392\u5230\u4e86\u6700\u524d\u9762\n         {\n             if (arr[j] &lt; arr[j - 1])\/\/\u5982\u679c\u524d\u4e00\u4e2a\u6570\u5927\u4e8e\u540e\u4e00\u4e2a\u6570\uff0c\u5c31\u4ea4\u6362\u4f4d\u7f6e\n             {\n                 temp = arr[j - 1];\n                 arr[j - 1] = arr[j];\n                 arr[j] = temp;\n                 tag = true;\n             }\n         }\n     }\n }<\/pre>\n\n\n\n<p class=\"has-medium-font-size\"><strong>\u4e09\u3001\u9009\u62e9\u6392\u5e8f<\/strong><\/p>\n\n\n\n<p>\u5c06\u7b2c\u4e00\u4e2a\u6570\u548c\u540e\u9762\u7684\u6bcf\u4e00\u4e2a\u6570\u4f5c\u6bd4\u8f83\uff0c\u627e\u51fa\u6700\u5c0f\u7684\u6570\u7684\u4e0b\u6807\uff08\u6240\u4ee5\u6bcf\u6b21\u90fd\u9700\u8981\u904d\u5386\u5b8c\u624d\u77e5\u9053\u8c01\u6700\u5c0f\uff09\u3002\u627e\u5230\u6700\u5c0f\u7684\u65f6\u5019\uff0c\u5c31\u4ea4\u6362\u4ed6\u4fe9\u7684\u4f4d\u7f6e\u3002\u8fd9\u6837\u5c31\u9009\u51fa\u6700\u5c0f\u503c\u653e\u5728\u7b2c\u4e00\u4f4d\u4e86\uff0c\u7136\u540e\u627e\u91cd\u590d\u64cd\u4f5c\u627e\u6b21\u5c0f\u503c\uff08++i\uff09\u3002\u76f4\u5230\u6392\u5e8f\u5b8c\u6210<br>\u9009\u62e9\u6392\u5e8f\u7684\u8fed\u4ee3\u6b21\u6570\u5176\u5b9e\u548c\u66b4\u529b\u6392\u5e8f\u662f\u4e00\u6837\u7684\uff0c\u4f46\u662f\u9009\u62e9\u6392\u5e8f\u51cf\u5c11\u4e86\u4ea4\u6362\u6b21\u6570\uff0c\u4e0d\u7528\u8bf4\u6bcf\u6b21\u4e00\u6bd4\u4ed6\u5c0f\u5c31\u6362\u4f4d\u7f6e\uff0c\u800c\u662f\u627e\u5230\u6700\u5c0f\u503c\u624d\u6362<br>\uff08\u5373\u5c06\u4ea4\u6362\u8bed\u53e5\u653e\u5728\u4e86\u7b2c\u4e8c\u4e2a\u5faa\u73af\u7684\u5916\u9762\uff09<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">void SelectSort(vector&lt;int>&amp; arr)\n {\n     int temp,min_index, len = arr.size();\n     for (int i = 0; i &lt; len - 1; ++i)\n     {\n         min_index = i;\/\/min_index\u8bb0\u5f55\u6700\u5c0f\u503c\u7684\u4e0b\u6807\n         for (int j = i + 1; j &lt; len; ++j)\n         {\n             if (arr[min_index] > arr[j])\/\/\u8fdb\u5165\u91cc\u9762\u5c31\u8bf4\u660e\u80fd\u627e\u5230\u66f4\u5c0f\u7684\u503c\n             {\n                 min_index = j;\n             }\n         }\n         if (min_index != i)\/\/\u627e\u5230\u4e86\u6bd4\u539f\u672c\u5f53\u524d\u4f4d\u7f6ei\u66f4\u5c0f\u7684\u503c\u5c31\u4ea4\u6362\n         {\n             temp = arr[min_index];\n             arr[min_index] = arr[i];\n             arr[i] = temp;\n         }\n     }\n }<\/pre>\n\n\n\n<p class=\"has-medium-font-size\"><strong>\u56db\u3001\u63d2\u5165\u6392\u5e8f<\/strong><\/p>\n\n\n\n<p>\u628a\u6bcf\u4e2a\u6570\u548c\u4e0a\u4e00\u4e2a\u76f8\u6bd4\uff0c\u5982\u679c\u8fd9\u4e2a\u6570\u5c0f\u4e8e\u4e0a\u4e00\u4e2a\u6570\u5c31\u8003\u8651\u5c06\u8fd9\u4e2a\u6570\u5f80\u524d\u63d2\uff0c\u81f3\u4e8e\u63d2\u5230\u4ec0\u4e48\u4f4d\u7f6e\uff0c\u5c31\u770b\u8fd9\u4e2a\u6570\u7684\u5927\u5c0f\uff0c\u4ed6\u8981\u548c\u524d\u9762\u7684\u6bcf\u4e00\u4e2a\u6570\u76f8\u6bd4\uff0c\u82e5\u662f\u5c0f\u4e8e\u5c31\u4e00\u76f4\u5f80\u524d\u8d70\uff0c\u76f4\u5230\u6392\u5728\u67d0\u4e2a\u6bd4\u4ed6\u5c0f\u7684\u6570\u7684\u540e\u9762\uff08\u7136\u540e\u4ed6\u540e\u9762\u7684\u6570\u5c31\u5f80\u540e\u632a\u4f4d\u7f6e\u7ed9\u4ed6\uff09\u3002\uff08\u5982\u679c\u6bd4\u6240\u6709\u6570\u5c0f\u5c31\u6392\u7b2c\u4e00\u4e86\uff09<br> \u8fd9\u79cd\u7b97\u6cd5\u5982\u679c\u5012\u5e8f\u6bd4\u8f83\u591a\u7684\u8bdd\uff0c\u5176\u5b9e\u6548\u7387\u5e76\u4e0d\u6bd4\u9009\u62e9\u7b97\u6cd5\u9ad8\uff0c<br> \u4f46\u5982\u679c\u662f\u5b8c\u5168\u4e71\u5e8f\uff0c\u8fd9\u662f\u4e00\u79cd\u6bd4\u8f83\u5feb\u7684\u7b97\u6cd5\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">void InsertSort(vector&lt;int>&amp; arr)\n {\n     int temp,j, len = arr.size();\n     for (int i = 1; i &lt; len; ++i)\n     {\n         if (arr[i] &lt; arr[i - 1])\n         {\n             temp = arr[i];\n             for (j = i-1; arr[j]>temp; --j)\n             {\n                 arr[j+1] = arr[j];\n                 if (j == 0)\n                 {\n                     --j;\n                     break;\n                 }\n             }\n             arr[j+1] = temp;\n         }\n     }\n }<\/pre>\n\n\n\n<p class=\"has-medium-font-size\"><strong>\u4e94\u3001\u5e0c\u5c14\u6392\u5e8f<\/strong><\/p>\n\n\n\n<p>\u63d2\u5165\u6392\u5e8f\u7684\u5347\u7ea7\u7248\uff0c\u63d2\u5165\u6392\u5e8f\u662f\u6bcf\u6b21\u548c\u4ed6\u4e0a\u4e00\u4e2a\u6bd4\u8f83\uff0c<br>\u5e0c\u5c14\u6392\u5e8f\u662f\u7b2c\u4e00\u8f6e\u548c\u4ed6\u524dgap\u4e2a\u6bd4\u8f83\uff0c\u5c31\u662f\u628aarr[i]\u548carr[i-gap]\u6bcf\u4e24\u4e2a\u6570\u5f53\u6210\u4e00\u7ec4\u63d2\u5165\u6392\u5e8f\uff0c\u8fdb\u884c\u6392\u5e8f\u3002(\u4e00\u5171\u6709gap\u7ec4)<br>\u7b2c\u4e8c\u8f6e\u662fgap\u7f29\u5c0f\u4e00\u500d\uff0c\u628aarr[i-gap]\uff0carr[i]\uff0carr[i+gap]\uff0carr[i+2*gap]\u6bcf\u56db\u4e2a\u6570\u5f53\u6210\u4e00\u7ec4\u63d2\u5165\u6392\u5e8f\u3002\uff08\u4e00\u5171\u6709gap\u7ec4\uff09<br> \u2026<br>\u4f9d\u6b21\u7c7b\u63a8<br>\u4e00\u822c\u6765\u8bb2\u53ea\u8981\u7406\u89e3\u4e86\u63d2\u5165\u6392\u5e8f\uff0c\u7136\u540e\u518d\u63d2\u5165\u6392\u5e8f\u7684\u57fa\u7840\u4e0a\u52a0\u4e2a\u5916\u5faa\u73af\uff0c\u518d\u628a\u539f\u672c\u7684\u95f4\u96941\uff0c\u6539\u6210gap\u5373\u53ef<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">void HillSort(vector&lt;int>&amp; arr)\n {\n     int temp, j, len = arr.size(),gap;\n     gap = len;\n     do\n     {\n          gap = gap\/2;\n          for (int i = gap; i &lt; len; i+=gap)\n          {\n               if (arr[i] &lt; arr[i - gap])\n               {\n                    temp = arr[i];\n                    for (j = i - gap; arr[j] > temp; j-=gap)\n                    {\n                         arr[j + gap] = arr[j];\n                         if (j == 0)\n                         {\n                             j-=gap;\n                             break; \n                          }\n                    }\n                    arr[j + gap] = temp;\n                }\n          }\n     } while (gap > 1);\n }<\/pre>\n\n\n\n<p class=\"has-medium-font-size\"><strong>\u516d\u3001\u5f52\u5e76\u6392\u5e8f<\/strong><\/p>\n\n\n\n<p>\u4e3b\u8981\u601d\u60f3\u662f\u5148\u5c06n\u957f\u7684\u6570\u7ec4\u65e0\u9650\u4e8c\u5206\uff0c\u76f4\u5230\u6bcf\u4efd\u90fd\u53ea\u6709\u4e24\u4e2a\u6570\uff0c\u7136\u540e\u5c06\u8fd9\u4e24\u4e2a\u6570\u6392\u5e8f\uff0c\u91cd\u65b0\u56de\u9000\u5230\u4e0a\u4e00\u5c42\uff08\u6bcf\u4efd\u53ea\u6709\u56db\u4e2a\u6570\u7684\u65f6\u5019\uff09\u518d\u8fdb\u884c\u6392\u5e8f\uff0c\u5728\u539f\u6765\u4e24\u4e2a\u4e24\u4e2a\u5df2\u6709\u987a\u5e8f\u7684\u57fa\u7840\u4e0a\uff0c\u8fd9\u662f\u6bd4\u8f83\u597d\u6392\u5e8f\u7684\uff0c\u6392\u5b8c\u540e\u53c8\u56de\u9000\u5230\u4e0a\u4e00\u5c42<br>\u4f9d\u6b21\u7c7b\u63a8<br>\u7528\u9012\u5f52\u7684\u601d\u60f3\u6bd4\u8f83\u597d\u5b9e\u73b0\uff0c\u4f46\u9012\u5f52\u6709\u70b9\u5f71\u54cd\u6548\u7387\u4e86<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">void merging(vector&lt;int>::iterator begin1, vector::iterator&lt;int> end1, vector::iterator&lt;int> begin2, vector::iterator&lt;int> end2)\n {\n     auto t1 = begin1, t2 = begin2;\n     vector t3;\n     while (end1 > t1&amp;&amp; end2 > t2)\n     {\n         if (*t1 &lt; *t2)\n         {\n              t3.push_back(t1);\n              ++t1;\n         }\n         else\n         {\n             t3.push_back(t2);\n             ++t2;\n         }\n     }\n     while (t1 &lt; end1)\n     {\n         t3.push_back(t1);\n         ++t1;\n     }\n     while (t2 &lt; end1)\n     {\n         t3.push_back(t2);\n         ++t2;\n     }\n     t1 = begin1;\n     for (int i = 0; i &lt; t3.size(); ++i)\n     {\n         *t1 = t3[i];\n         ++t1;\n     }\n }\nvoid MeregeSort(vector&lt;int>::iterator begin, vector&lt;int>::iterator end)\n {\n     if (end-begin > 1)\n     {\n         auto new_begin1 = begin;\n         auto new_end1 = begin+(end- begin)\/2;\n         auto new_begin2 = begin + (end - begin) \/ 2 ;\n         auto new_end2 = end;\n         MeregeSort(new_begin1, new_end1);\n         MeregeSort(new_begin2, new_end2);\n         merging(new_begin1, new_end1, new_begin2, new_end2);\n     }\n }<\/pre>\n\n\n\n<p class=\"has-medium-font-size\"><strong>\u4e03\u3001\u5806\u6392\u5e8f<\/strong><\/p>\n\n\n\n<p>\u662f\u7b80\u5355\u9009\u62e9\u6392\u5e8f\u7684\u5347\u7ea7\u7248\u3002<br>\u53ef\u4ee5\u7406\u89e3\u4e3a\u6570\u7ec4\u662f\u6309\u5b8c\u5168\u4e8c\u53c9\u6811\u5c42\u53e0\u6392\u5217\u7684\uff0c\u4ece\u6700\u53f3\u4e0b\u5c0f\u4e8c\u53c9\u6811\u8d77\uff0c\u5c06\u4e09\u4e2a\u6570\u9009\u51fa\u6700\u5927\u7684\u4e00\u4e2a\u6392\u5230\u6839\u7684\u4f4d\u7f6e\u3002\u7ee7\u7eed\u4ece\u53f3\u5230\u5de6\u4ece\u4e0a\u5230\u4e0b\u4f9d\u6b21\u6267\u884c\uff0c\u6267\u884c\u5b8c\u540e\uff0c\u6839\u90e8\u7684\u4f4d\u7f6e\u5373\u5f53\u524d\u6700\u5927\u503c\uff08\u5373\u6570\u7ec4\u91cc\u7b2c0\u4f4d\uff09\u3002\u7136\u540e\u5c06\u8fd9\u4e2a\u6700\u5927\u503c\u653e\u5230\u5b8c\u5168\u4e8c\u53c9\u6811\u6700\u672b\u4f4d\uff0c\uff08\u6570\u7ec4\u91cc\u6700\u540e\u4e00\u4f4d\uff09\uff0c\u7136\u540e\u518d\u4f9d\u6b21\u7c7b\u63a8\u9009\u51fa\u7b2c\u4e8c\u5927\uff0c\u7b2c\u4e09\u5927\u3002\u3002\u3002\u6700\u7ec8\u5b8c\u6210\u6392\u5e8f\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">void SwapTheMax(vector&lt;int>&amp; arr, int i, int len)\n {\n     int max_index = i;\n     if (2 * i + 1 &lt; len &amp;&amp; arr[max_index] &lt; arr[i * 2 + 1])\n         max_index = 2 * i + 1;\n     if (2 * i + 2 &lt; len &amp;&amp; arr[max_index] &lt; arr[i * 2 + 2])\n         max_index = 2 * i + 2;\n     if (max_index != i)\n     {\n         int temp = arr[i];\n         arr[i] = arr[max_index];\n         arr[max_index] = temp;\n         SwapTheMax(arr, max_index, len);\n     }\n }\n void HeapSort(vector&lt;int>&amp; arr)\n {\n     int len = arr.size();\n     while (len > 1)\n     {\n         \/\/\u521d\u59cb\u5316\u5806\n         for (int i = len \/ 2 - 1; i >= 0; --i)\n         {\n             SwapTheMax(arr, i, len);\n         }\n         int temp = arr[0];\n         arr[0] = arr[len - 1];\n         arr[len - 1] = temp;\n         \/\/\u4ea4\u6362\u5806\u9876\u548c\u5f53\u524d\u6700\u540e\u4e00\u4e2a\u7684\u4f4d\u7f6e\n         --len;\n     }\n }<\/pre>\n\n\n\n<p class=\"has-medium-font-size\"><strong>\u516b\u3001\u5feb\u901f\u6392\u5e8f<\/strong><\/p>\n\n\n\n<p>\u662f\u4e00\u79cd\u5192\u6ce1\u7b97\u6cd5\u7684\u5347\u7ea7\u7248\uff01<br> \u6bcf\u6b21\u53d6\u4e00\u4e2a\u6570\u7ec4\u4e2d\u7684\uff08\u5f53\u524d\u7b2c\u4e00\u4f4d\uff09\u4e00\u4e2a\u6570\u4f5c\u4e3a\u57fa\u51c6\u70b9\uff0c\u7136\u540e\u628a\u6570\u7ec4\u91cc\u5927\u4e8e\u4ed6\u7684\u6570\u653e\u5728\u53f3\u8fb9\uff0c\u5c0f\u4e8e\u5b83\u7684\u6570\u653e\u5728\u5de6\u8fb9\uff0c\u628a\u5de6\u8fb9\u548c\u53f3\u8fb9\u53c8\u770b\u6210\u662f\u4e00\u4e2a\u6570\u7ec4\uff0c\u8fdb\u884c\u9012\u5f52\u64cd\u4f5c\u3002\u5f53\u6570\u7ec4\u91cc\u9012\u5f52\u5230\u53ea\u5269\u4e00\u4e2a\u6570\u7684\u65f6\u5019\u5c31\u8fd4\u56de\u3002\u6700\u7ec8\u5c31\u80fd\u5b9e\u73b0\u4e00\u4e2a\u6392\u5e8f\u6548\u679c\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">int CalculatePoint(vector&lt;int>::iterator begin, vector&lt;int>::iterator end)\n {\n     int point = begin;\n     auto e = end-1, b = begin;\n     while (e - b > 0)\n     {\n         while (b &lt; e)\n         {\n             if (e &lt; point)\n             {\n                 int temp = *e;\n                 *e = point;\n                 b = temp;\n                 break;\n             }\n             --e;\n         }\n         while (b &lt; e)\n         {\n             if (b > point)\n             {\n                 int temp = *b;\n                 *b = point;\n                 *e = temp;\n                 break;\n             }\n             ++b;\n         }\n     }\n     return (b - begin);\n }\nvoid QuickSort(vector&lt;int>::iterator begin, vector&lt;int>::iterator end)\n {\n     if (end - begin > 1)\n     {\n         int point = CalculatePoint(begin, end);\n         QuickSort(begin, begin + point+1);\n         QuickSort(begin + point+1, end);\n     }\n }<\/pre>\n\n\n\n<p class=\"has-medium-font-size\"><strong>\u5f00\u59cb\u6d4b\u8bc4<\/strong><\/p>\n\n\n\n<p>\u751f\u6210999\u4e2a\u6d4b\u8bd5\u6570\u636e<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1245\" height=\"1080\" src=\"https:\/\/www.notown.club\/wp-content\/uploads\/2020\/04\/\u5fae\u4fe1\u622a\u56fe_20200419120856.png\" alt=\"\" class=\"wp-image-448\"\/><\/figure>\n\n\n\n<p>\u5404\u6392\u5e8f\u7b97\u6cd5\u8017\u65f6<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"360\" height=\"468\" src=\"https:\/\/www.notown.club\/wp-content\/uploads\/2020\/04\/image.png\" alt=\"\" class=\"wp-image-449\"\/><figcaption>\u6539\u8fdb\u540e\u7684\u5e0c\u5c14\u6392\u5e8f\u600e\u4e48\u4f1a\u6bd4\u63d2\u5165\u6392\u5e8f\u8fd8\u6162\u5462[\u65fa\u67f4]<br>headsort\u662f\u540e\u6765\u52a0\u7684\uff0c\u8fd9\u91cc\u6ca1\u6d4b\u8bc4<\/figcaption><\/figure><\/div>\n\n\n\n<p>\u6362\u4e86\u7ec4\u6570\u636e\u518d\u6d4b<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"137\" height=\"497\" src=\"https:\/\/www.notown.club\/wp-content\/uploads\/2020\/04\/image-1.png\" alt=\"\" class=\"wp-image-450\"\/><figcaption>emm\u3001\u3001\u53cd\u6b63\u5927\u81f4\u5c31\u8fd9\u6837\u5427\uff0c\u5404\u6392\u5e8f\u7b97\u6cd5\u4e5f\u662f\u53d7\u6570\u636e\u5f71\u54cd\uff0c\u6392\u5e8f\u901f\u5ea6\u6709\u6240\u504f\u5dee\u7684<\/figcaption><\/figure><\/div>\n\n\n\n<p>\u7ed3\u8bba\uff1a<br>\u4e00\u4e9b\u7b80\u5355\u7684\u6392\u5e8f\u6bd4\u5982\u5192\u6ce1\u6392\u5e8f\u66b4\u529b\u6392\u5e8f\u901f\u5ea6\u662f\u6bd4\u8f83\u6162\u7684\uff0c\u9009\u62e9\u6392\u5e8f\u7684\u901f\u5ea6\u4e5f\u4e0d\u5feb\uff0c\u63d2\u5165\u6392\u5e8f\u7b80\u5355\u4f46\u662f\u901f\u5ea6\u8fd8\u7b97\u5feb\uff0c\u6539\u8fdb\u540e\u7684\u5e0c\u5c14\u6392\u5e8f\u6709\u4e00\u5b9a\u63d0\u5347\u3002\u5f52\u5e76\u6392\u5e8f\u7528\u4e86\u9012\u5f52\uff0c\u5b9e\u6d4b\u8d77\u6765\u53cd\u800c\u901f\u5ea6\u6162\u4e86\uff0c\u5feb\u901f\u6392\u5e8f\u5c31\u7b97\u7528\u4e86\u9012\u5f52\u901f\u5ea6\u4e5f\u5f88\u5feb\uff08\u5feb\u901f\u6392\u5e8f\u725b\u903c\uff01\uff09<\/p>\n\n\n\n<p>\u6700\u540e\u4e00\u53e5\u8bdd\u603b\u7ed3\uff1a<br><strong>\u6709STL\u5e93\u7684sort\u5728\uff0c\u5199\u4e2a\u5c41\u7684\u6392\u5e8f\uff0c\u6e9c\u4e86\u6e9c\u4e86<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b66\u6570\u636e\u7ed3\u6784\u548c\u7b97\u6cd5\u7684\u65f6\u5019\u63a5\u89e6\u5230\u4e86\u4e0d\u5c11\u6392\u5e8f\u7b97\u6cd5\uff0c\u5728\u8fd9\u91cc\u6574\u7406\u4e00\u4e0b\u3002\u6d89\u53ca\u5230\u7684\u6392\u5e8f\u7b97\u6cd5\u6709\u5192\u6ce1\u6392\u5e8f\u3001\u9009\u62e9\u6392\u5e8f\u3001\u63d2\u5165\u6392\u5e8f\u3001\u5e0c&hellip;<a href=\"https:\/\/www.notown.top\/?p=446\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">\u4e00\u4e9b\u6392\u5e8f\u7b97\u6cd5<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","footnotes":""},"categories":[11],"tags":[],"class_list":["post-446","post","type-post","status-publish","format-standard","hentry","category-c"],"_links":{"self":[{"href":"https:\/\/www.notown.top\/index.php?rest_route=\/wp\/v2\/posts\/446","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.notown.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.notown.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.notown.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.notown.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=446"}],"version-history":[{"count":8,"href":"https:\/\/www.notown.top\/index.php?rest_route=\/wp\/v2\/posts\/446\/revisions"}],"predecessor-version":[{"id":535,"href":"https:\/\/www.notown.top\/index.php?rest_route=\/wp\/v2\/posts\/446\/revisions\/535"}],"wp:attachment":[{"href":"https:\/\/www.notown.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=446"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.notown.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=446"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.notown.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=446"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}