{"id":37332,"date":"2025-05-15T22:27:19","date_gmt":"2025-05-15T14:27:19","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/37332.html"},"modified":"2025-05-15T22:27:19","modified_gmt":"2025-05-15T14:27:19","slug":"%e6%8e%92%e5%ba%8f%e7%ae%97%e6%b3%95-%e9%80%89%e6%8b%a9%e6%8e%92%e5%ba%8f","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/37332.html","title":{"rendered":"\u6392\u5e8f\u7b97\u6cd5-\u9009\u62e9\u6392\u5e8f"},"content":{"rendered":"<p>\u9009\u62e9\u6392\u5e8f\u662f\u4e00\u79cd\u7b80\u5355\u76f4\u89c2\u7684\u6392\u5e8f\u7b97\u6cd5&#xff0c;\u5176\u6838\u5fc3\u601d\u60f3\u662f\u6bcf\u6b21\u4ece\u672a\u6392\u5e8f\u7684\u90e8\u5206\u4e2d\u9009\u51fa\u6700\u5c0f&#xff08;\u6216\u6700\u5927&#xff09;\u7684\u5143\u7d20&#xff0c;\u653e\u5230\u5df2\u6392\u5e8f\u90e8\u5206\u7684\u672b\u5c3e\u3002<\/p>\n<h4>\u9009\u62e9\u6392\u5e8f\u6b65\u9aa4<\/h4>\n<li>\n<p>\u521d\u59cb\u5316&#xff1a;\u5c06\u5e8f\u5217\u5206\u4e3a\u5df2\u6392\u5e8f\u90e8\u5206&#xff08;\u521d\u59cb\u4e3a\u7a7a&#xff09;\u548c\u672a\u6392\u5e8f\u90e8\u5206&#xff08;\u521d\u59cb\u4e3a\u6574\u4e2a\u5e8f\u5217&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u67e5\u627e\u6700\u5c0f\u503c&#xff1a;\u904d\u5386\u672a\u6392\u5e8f\u90e8\u5206&#xff0c;\u627e\u5230\u6700\u5c0f\u7684\u5143\u7d20\u3002<\/p>\n<\/li>\n<li>\n<p>\u4ea4\u6362\u4f4d\u7f6e&#xff1a;\u5c06\u6700\u5c0f\u5143\u7d20\u4e0e\u672a\u6392\u5e8f\u90e8\u5206\u7684\u7b2c\u4e00\u4e2a\u5143\u7d20\u4ea4\u6362&#xff0c;\u5c06\u5176\u7eb3\u5165\u5df2\u6392\u5e8f\u90e8\u5206\u3002<\/p>\n<\/li>\n<li>\n<p>\u91cd\u590d\u8fc7\u7a0b&#xff1a;\u91cd\u590d\u4e0a\u8ff0\u6b65\u9aa4&#xff0c;\u76f4\u5230\u672a\u6392\u5e8f\u90e8\u5206\u4e3a\u7a7a\u3002<\/p>\n<\/li>\n<p style=\"text-align:center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250515142718-6825f9c63026f.gif\" \/><\/p>\n<h4>\u4ee3\u7801\u5b9e\u73b0<\/h4>\n<p>package Sort;<\/p>\n<p>public class SelectionSort {<br \/>\n    public static void main(String[] args) {<br \/>\n        int[] res &#061; getSelectionSort(new int[]{3,44,38,5,47,15,36,26,27,2,46,4,19,50,48});<br \/>\n        for (int i &#061; 0; i &lt; res.length; i&#043;&#043;) {<br \/>\n            System.out.print(res[i] &#043; &#034; &#034;);<br \/>\n        }<br \/>\n    }<br \/>\n    \/\/\u5347\u5e8f\u6392\u5217&#xff0c;\u67e5\u627e\u6700\u5c0f\u503c&#xff0c;\u5982\u679c\u964d\u5e8f\u6392\u5217&#xff0c;\u5219\u67e5\u627e\u6700\u5927\u503c<br \/>\n    public static int[] getSelectionSort(int[] nums){<br \/>\n        int len &#061; nums.length;<br \/>\n        for (int i &#061; 0; i &lt; len; i&#043;&#043;) {<br \/>\n            int minIndex &#061; i;\/\/\u6700\u5c0f\u6570\u7684\u4e0b\u6807&#xff0c;\u6bcf\u6b21\u5faa\u73af\u5f00\u59cb\u603b\u662f\u5047\u8bbe\u7b2c\u4e00\u4e2a\u6570\u6700\u5c0f<br \/>\n            for (int j &#061; i&#043;1; j &lt; len; j&#043;&#043;) {\/\/\u6bcf\u6b21\u5faa\u73af&#xff0c;\u67e5\u627e\u5269\u4f59\u7684\u6570\u7684\u6700\u5c0f\u503c<br \/>\n                if (nums[j] &lt; nums[minIndex]){<br \/>\n                    minIndex &#061; j; \/\/\u5c06\u6700\u5c0f\u6570\u7684\u5c0f\u6807\u4fdd\u5b58<br \/>\n                }<br \/>\n            }<br \/>\n            \/\/\u9000\u51fa\u5185\u5faa\u73af&#xff0c;\u5219\u8bf4\u660e\u627e\u5230\u5269\u4f59\u6570\u7684\u6700\u5c0f\u503c<br \/>\n            \/\/\u5c06\u5f53\u524d\u6570\u4e0e\u6700\u5c0f\u503c\u8fdb\u884c\u4ea4\u6362<br \/>\n            int temp &#061; nums[minIndex];<br \/>\n            nums[minIndex] &#061; nums[i];<br \/>\n            nums[i] &#061; temp;<br \/>\n        }<br \/>\n        return nums;<br \/>\n    }<br \/>\n}<\/p>\n<h4>\u65f6\u95f4\u590d\u6742\u5ea6<\/h4>\n<li>\n<p>\u6700\u574f\u60c5\u51b5&#xff1a;\u65e0\u8bba\u8f93\u5165\u662f\u5426\u6709\u5e8f&#xff0c;\u6bcf\u6b21\u90fd\u9700\u8981\u5b8c\u6574\u904d\u5386\u672a\u6392\u5e8f\u90e8\u5206\u3002<\/p>\n<ul>\n<li>\n<p>\u6bd4\u8f83\u6b21\u6570&#xff1a;(n-1) &#043; (n-2) &#043; &#8230; &#043; 1 &#061; n(n-1)\/2&#xff0c;\u5373\u00a0O(n\u00b2)\u3002<\/p>\n<\/li>\n<li>\n<p>\u4ea4\u6362\u6b21\u6570&#xff1a;\u6bcf\u6b21\u904d\u5386\u6700\u591a\u4ea4\u6362\u4e00\u6b21&#xff0c;\u5171\u00a0n-1\u00a0\u6b21&#xff0c;\u5373\u00a0O(n)\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u6700\u597d\u60c5\u51b5&#xff1a;\u5373\u4f7f\u5e8f\u5217\u5df2\u7ecf\u6709\u5e8f&#xff0c;\u4ecd\u9700\u5b8c\u6210\u6240\u6709\u6bd4\u8f83&#xff0c;\u56e0\u6b64\u4ecd\u662f\u00a0O(n\u00b2)\u3002<\/p>\n<\/li>\n<li>\n<p>\u5e73\u5747\u60c5\u51b5&#xff1a;\u65f6\u95f4\u590d\u6742\u5ea6\u4e3a\u00a0O(n\u00b2)\u3002<\/p>\n<\/li>\n<h4>\u7a7a\u95f4\u590d\u6742\u5ea6<\/h4>\n<ul>\n<li>\n<p>\u9009\u62e9\u6392\u5e8f\u662f\u539f\u5730\u6392\u5e8f&#xff0c;\u4ec5\u9700\u5e38\u6570\u7ea7\u989d\u5916\u7a7a\u95f4&#xff08;\u7528\u4e8e\u4e34\u65f6\u4ea4\u6362&#xff09;&#xff0c;\u56e0\u6b64\u7a7a\u95f4\u590d\u6742\u5ea6\u4e3a\u00a0O(1)\u3002<\/p>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb393\u6b21\uff0c\u70b9\u8d5e10\u6b21\uff0c\u6536\u85cf4\u6b21\u3002\u9009\u62e9\u6392\u5e8f\u662f\u4e00\u79cd\u7b80\u5355\u76f4\u89c2\u7684\u6392\u5e8f\u7b97\u6cd5\uff0c\u5176\u6838\u5fc3\u601d\u60f3\u662f\u3002<\/p>\n","protected":false},"author":2,"featured_media":37331,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[99,3226,3227],"topic":[],"class_list":["post-37332","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-java","tag-3226","tag-3227"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u6392\u5e8f\u7b97\u6cd5-\u9009\u62e9\u6392\u5e8f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/37332.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u6392\u5e8f\u7b97\u6cd5-\u9009\u62e9\u6392\u5e8f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb393\u6b21\uff0c\u70b9\u8d5e10\u6b21\uff0c\u6536\u85cf4\u6b21\u3002\u9009\u62e9\u6392\u5e8f\u662f\u4e00\u79cd\u7b80\u5355\u76f4\u89c2\u7684\u6392\u5e8f\u7b97\u6cd5\uff0c\u5176\u6838\u5fc3\u601d\u60f3\u662f\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/37332.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-05-15T14:27:19+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250515142718-6825f9c63026f.gif\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/37332.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/37332.html\",\"name\":\"\u6392\u5e8f\u7b97\u6cd5-\u9009\u62e9\u6392\u5e8f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-05-15T14:27:19+00:00\",\"dateModified\":\"2025-05-15T14:27:19+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/37332.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/37332.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/37332.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u6392\u5e8f\u7b97\u6cd5-\u9009\u62e9\u6392\u5e8f\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u6392\u5e8f\u7b97\u6cd5-\u9009\u62e9\u6392\u5e8f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/37332.html","og_locale":"zh_CN","og_type":"article","og_title":"\u6392\u5e8f\u7b97\u6cd5-\u9009\u62e9\u6392\u5e8f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb393\u6b21\uff0c\u70b9\u8d5e10\u6b21\uff0c\u6536\u85cf4\u6b21\u3002\u9009\u62e9\u6392\u5e8f\u662f\u4e00\u79cd\u7b80\u5355\u76f4\u89c2\u7684\u6392\u5e8f\u7b97\u6cd5\uff0c\u5176\u6838\u5fc3\u601d\u60f3\u662f\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/37332.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-05-15T14:27:19+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/05\/20250515142718-6825f9c63026f.gif"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"1 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/37332.html","url":"https:\/\/www.wsisp.com\/helps\/37332.html","name":"\u6392\u5e8f\u7b97\u6cd5-\u9009\u62e9\u6392\u5e8f - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-05-15T14:27:19+00:00","dateModified":"2025-05-15T14:27:19+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/37332.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/37332.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/37332.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u6392\u5e8f\u7b97\u6cd5-\u9009\u62e9\u6392\u5e8f"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/37332","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=37332"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/37332\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/37331"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=37332"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=37332"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=37332"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=37332"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}