{"id":227,"date":"2022-09-07T16:51:51","date_gmt":"2022-09-07T08:51:51","guid":{"rendered":"https:\/\/courtship.top\/?p=227"},"modified":"2022-09-07T16:51:51","modified_gmt":"2022-09-07T08:51:51","slug":"%e5%b8%8c%e5%b0%94%e6%8e%92%e5%ba%8f","status":"publish","type":"post","link":"https:\/\/courtship.top\/index.php\/2022\/09\/07\/%e5%b8%8c%e5%b0%94%e6%8e%92%e5%ba%8f\/","title":{"rendered":"\u5e0c\u5c14\u6392\u5e8f"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>#include &lt;bits\/stdc++.h&gt;\nusing namespace std;\n\n\/\/\u5e0c\u5c14\u6392\u5e8f\n\/\/\u63d2\u5165\u6392\u5e8f\u7684\u4f18\u5316\u7248 \u4f18\u5316\u4e86\u4ea4\u6362\u6570\u503c\u7684\u8fc7\u7a0b\n\/\/\u5b9a\u4e49\u4e00\u4e2a\u603b\u957f\u5ea6 \/ 2\u7684\u6b65\u957f \u5e76\u4e0d\u65ad\u5730\u6298\u534a\u4ed6\n\/\/\u4ee5\u6b65\u957f\u4e3a\u957f\u5ea6\u5728\u6570\u7ec4\u4e2d\u8fdb\u884c\u63d2\u5165\u6392\u5e8f\n\nvector&lt;int&gt; nums = {1, 2, 3, 5, 6, 3, 2, 4, 6, 8};\n\nvoid print(vector&lt;int&gt; num)\n{\n    for (vector&lt;int&gt;::iterator it = num.begin(); it != num.end(); it++)\n    {\n        cout &lt;&lt; *it &lt;&lt; \" \";\n    }\n}\n\nvoid shell_sort(vector&lt;int&gt; num, int n)\n{\n    int i = 0;\n    int j = 0;\n    int temp = 0;\n\n    for (int step = n; step &gt; 0; step = step \/ 2) \/\/\u6b65\u957f\u516c\u5f0f\n    {\n        for (i = step; i &lt; n; i++) \/\/\u4ece\u6b65\u957f\u5f00\u59cb\n        {\n            temp = num&#91;i];\n            for (j = i; j &gt; step &amp;&amp; temp &lt; num&#91;j - step]; j -= step)\n            {\n                num&#91;j] = num&#91;j - step];\n            }\n            num&#91;j] = temp;\n        }\n    }\n    print(num);\n}\n\nint main()\n{\n    shell_sort(nums, nums.size());\n    return 0;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"emotion":"","emotion_color":"","title_style":"","license":"","footnotes":""},"categories":[16],"tags":[],"class_list":["post-227","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/courtship.top\/index.php\/wp-json\/wp\/v2\/posts\/227","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/courtship.top\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/courtship.top\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/courtship.top\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/courtship.top\/index.php\/wp-json\/wp\/v2\/comments?post=227"}],"version-history":[{"count":0,"href":"https:\/\/courtship.top\/index.php\/wp-json\/wp\/v2\/posts\/227\/revisions"}],"wp:attachment":[{"href":"https:\/\/courtship.top\/index.php\/wp-json\/wp\/v2\/media?parent=227"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courtship.top\/index.php\/wp-json\/wp\/v2\/categories?post=227"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courtship.top\/index.php\/wp-json\/wp\/v2\/tags?post=227"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}