{"id":271,"date":"2019-03-25T07:38:56","date_gmt":"2019-03-24T23:38:56","guid":{"rendered":"https:\/\/h-k.pw\/?p=271"},"modified":"2019-04-04T22:05:58","modified_gmt":"2019-04-04T14:05:58","slug":"series-of-sort","status":"publish","type":"post","link":"https:\/\/harson.co\/index.php\/2019\/03\/25\/series-of-sort\/","title":{"rendered":"Series of Sort"},"content":{"rendered":"<h1>\u5192\u6ce1\u6392\u5e8f<\/h1>\n<pre class=\"pure-highlightjs\"><code class=\"\">void bubble_sort(int *a, int n)\r\n{\r\n\tint temp;\r\n\tfor(int i=0;i&lt;n-1;i++)\r\n\t{\r\n\t\tfor(int j=0;j&lt;n-1;j++)\r\n\t\t{\r\n\t\t\tif(a[j]&lt;j[j+1])\r\n\t\t\t{\r\n\t\t\t\ttemp=a[j];\r\n\t\t\t\ta[j]=a[j+1];\r\n\t\t\t\ta[j+1]=temp;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}<\/code><\/pre>\n<h1><\/h1>\n<h1>\u5feb\u901f\u6392\u5e8f<\/h1>\n<pre class=\"pure-highlightjs\"><code class=\"\">void quick_sort(int *a, int left, int right)\r\n{\r\n\tint j, i, tem;\r\n\t\r\n\t\r\n\t\/\/\u5de6\u6807\u4e0d\u80fd\u5927\u4e8e\u53f3\u6807\r\n\tif(left&gt;right)\r\n\t{\r\n\t\treturn;\r\n\t}\r\n\t\r\n\t\/\/\u4ece\u5de6\u5f00\u59cb\u7b2c\u4e00\u4e2a\u4f5c\u4e3a\u53c2\u8003\u503c\r\n\ttem = a[left];\r\n\ti = left;\r\n\tj = right;\r\n\t\r\n\t\/\/\u5de6\u53f3\u4e24\u8fb9\u672a\u76f8\u9047\u65f6\uff0c\u6301\u7eed\u4ea4\u6362\r\n\twhile(j!=i)\r\n\t{\r\n\t\t\/\/\u53f3\u8fb9\u6bd4\u53c2\u8003\u5927\uff0c\u8bf4\u660e\u4f4d\u7f6e\u4e0d\u6b63\u786e\uff0c\u505c\u4e0b\u7b49\u5f85\u4ea4\u6362\r\n\t\twhile(a[j]&gt;=tem)\r\n\t\t{\r\n\t\t\tj--;\r\n\t\t}\r\n\r\n\t\t\/\/\u5de6\u8fb9\u6bd4\u53c2\u8003\u5c0f\uff0c\u8bf4\u660e\u4f4d\u7f6e\u4e0d\u6b63\u786e\uff0c\u505c\u4e0b\u7b49\u5f85\u4ea4\u6362\r\n\t\twhile(a[i]&lt;=tem)\r\n\t\t{\r\n\t\t\ti++;\r\n\t\t}\r\n\t\t\/\/\u53f3\u8fb9\u4e0d\u80fd\u8d85\u8fc7\u53f3\u8fb9\r\n\t\tif(j&gt;i)\r\n\t\t{\r\n\t\t\t\/\/\u5c06\u4e24\u4e2a\u4f4d\u7f6e\u4e0d\u6b63\u786e\u7684\u503c\u4ea4\u6362\u4f4d\u7f6e\r\n\t\t\ta[j] = a[i];\r\n\t\t\ta[i] = tem;\r\n\t\t}\r\n\t\r\n\t}\r\n\t\/\/\u9012\u5f52\u5904\u7406\u5b50\u6570\u7ec4\r\n\tquick_sort(a, left, j+1);\r\n\tquick_sort(a, i+1, right);\r\n}<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5192\u6ce1\u6392\u5e8f void bubble_sort(int *a, int n) { int temp; for(in [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-271","post","type-post","status-publish","format-standard","hentry","category-pta"],"_links":{"self":[{"href":"https:\/\/harson.co\/index.php\/wp-json\/wp\/v2\/posts\/271","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/harson.co\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/harson.co\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/harson.co\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/harson.co\/index.php\/wp-json\/wp\/v2\/comments?post=271"}],"version-history":[{"count":3,"href":"https:\/\/harson.co\/index.php\/wp-json\/wp\/v2\/posts\/271\/revisions"}],"predecessor-version":[{"id":276,"href":"https:\/\/harson.co\/index.php\/wp-json\/wp\/v2\/posts\/271\/revisions\/276"}],"wp:attachment":[{"href":"https:\/\/harson.co\/index.php\/wp-json\/wp\/v2\/media?parent=271"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/harson.co\/index.php\/wp-json\/wp\/v2\/categories?post=271"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/harson.co\/index.php\/wp-json\/wp\/v2\/tags?post=271"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}