{"id":639,"date":"2023-12-17T18:01:01","date_gmt":"2023-12-17T10:01:01","guid":{"rendered":""},"modified":"2023-12-17T18:01:01","modified_gmt":"2023-12-17T10:01:01","slug":"java\u7684\u5192\u6ce1\u6392\u5e8f\u6cd5","status":"publish","type":"post","link":"https:\/\/mushiming.com\/639.html","title":{"rendered":"java\u7684\u5192\u6ce1\u6392\u5e8f\u6cd5"},"content":{"rendered":"

\n <\/path> \n<\/svg> <\/p>\n

\u5927\u5bb6\u597d\uff0c\u6211\u662f\u5c0f\u94c1\uff0c\u4eca\u5929\u53c8\u662f\u5199bug\u7684\u4e00\u5929\u2026<\/em>
\"java\u7684\u5192\u6ce1\u6392\u5e8f\u6cd5<\/p>\n

\u4e00\u4e36\u4eca\u5929\u6211\u4eec\u6765\u8bb2\u8bb2java\u4e2d\u7684\u5192\u6ce1\u6392\u5e8f\u6cd5\uff08\u8001\u9e1f\u8bf7\u76f4\u63a5\u62f7\u8d70\u4e0b\u9762\u7684\u4ee3\u7801\uff09,\u5e9f\u8bdd\u4e0d\u591a\u8bf4\uff0c\u76f4\u63a5\u4e0a\u4ee3\u7801<\/strong><\/p>\n

package com.cn.tie;\n\n\npublic class Test {\n\n    public static void main(String[] args) {\n\n        Integer sum[] = {1,3,2,6,8,4};\n\n        for(int i=0; i<sum.length-1; i++ ){ \n            for(int j=i+1; j<= sum.length-1; j++){  \n                if(sum[j] > sum[i]){  \/\/\u4ea4\u6362\u503c\n                    Integer arr = 0;\n                    arr = sum[i];\n                    sum[i] = sum[j];\n                    sum[j] = arr;\n                }\n            }\n        }\n        for(int i=0; i<sum.length; i++){\n            System.out.println(sum[i]);\n        }\n    }\n}\n\n<\/code><\/pre>\n
\n

\u4e8c\u4e36\u8bb2\u89e3\u601d\u8def<\/em><\/h2>\n

1.\u540d\u79f0\uff1a<\/strong>
\u5192\u6ce1\u6392\u5e8f\u6cd5<\/p>\n

2.\u5b9e\u73b0\u601d\u8def\uff1a<\/strong>
\u7528\u76f8\u90bb\u7684\u4e24\u4e2a\u6570\uff0c\u8fdb\u884c\u6bd4\u8f83\u3002\u7b2c\u4e00\u4e2a\u548c\u7b2c\u4e8c\u4e2a\u6bd4\u8f83\uff0c\u5982\u679c\u7b2c\u4e8c\u4e2a\u6bd4\u7b2c\u4e00\u4e2a\u5927\u5c31\u8fdb\u884c\u4ea4\u6362\u3002\u628a\u6700\u5927\u7684\u653e\u5728\u7b2c\u4e00\u4f4d\uff0c\u6700\u540e\u62ff\u7740\u8fd9\u4e2a\u6700\u5927\u7684\u548c\u5269\u4f59\u7684\u76f8\u6bd4\u8f83\uff0c\u5982\u679c\u9047\u5230\u6bd4\u5b83\u8fd8\u5927\u7684\u5c31\u8fdb\u884c\u4ea4\u6362<\/p>\n

3.\u4ee3\u7801\u8bb2\u89e3\uff1a<\/strong>
\u7b2c\u4e00\u5c42for\u5faa\u73af\uff0c\u5f53i=0\u65f6\uff0c\u5b83\u7684\u503c\u4e3a1\uff0cj\u7684\u521d\u59cb\u503c\u4e3ai+1 \u4e5f\u5c31\u662f i \u7684\u524d\u4e00\u4e2a\u6570\u5b57\uff0c\u5bf9\u5e94\u7684\u503c\u4e3a3\u3002\u7ee7\u7eed\u8d70\uff0c\u4e24\u4e2a\u503c\u8fdb\u884c\u6bd4\u8f83 3 \u6bd4 1 \u5927 \u5c31\u8fdb\u884c\u4ea4\u6362\u3002\u8fd9\u65f6\u5c31\u8981\u6ce8\u610f\u4e86 \u503c\u5df2\u7ecf\u4ea4\u6362\u8fc7\u6765\u4e86 \u73b0\u5728i=0\u7684\u65f6\u5019 \u5bf9\u5e94\u7684\u503c\u4e3a3\u4e86\u4e0d\u662f1\u4e86 \u56e0\u4e3a\u8fdb\u884c\u4e86\u4ea4\u6362\u3002j \u63a7\u5236\u7740\u5185\u5c42for\u5faa\u73af \u5206\u522b\u5faa\u73af\u5269\u4e0b\u7684\u5185\u5bb9\u548ci=0\u7684\u503c\u8fdb\u884c\u6bd4\u8f83\uff0c\u5982\u679c\u9047\u5230\u5927\u7684\u5c31\u8fdb\u884c\u4ea4\u6362\u3002\u56e0\u4e3a i \u4e0e j \u90fd\u662f\u4ee3\u8868\u7684\u6570\u7ec4\u4e0b\u6807 \u6240\u4ee5 \u7b2c\u4e00\u5c42\u5faa\u73af\u4e3a \u6570\u7ec4\u7684\u5927\u5c0f\u5df2\u51cf\u53bb\u4e00\uff0c\u56e0\u4e3a\u4e0b\u6807\u4ece0\u5f00\u59cb\uff0c\u5185\u5c42\u5faa\u73af\u62ff\u5230\u5269\u4f59\u7684\u6570\u8fdb\u884c\u4e0ei\u4e0b\u6807\u7684\u503c\u8fdb\u884c\u6bd4\u8f83\uff0c\u56e0\u4e3a\u521d\u59cb\u503c\u4e3ai+1 \u968f\u7740i\u7684\u6539\u53d8\u800c\u6539\u53d8\u3002\u6240\u4ee5\u54b1\u4eec\u5185\u5c42\u5faa\u73af\u7684\u5927\u5c0f\u4e3a\u6570\u7ec4\u7684\u5927\u5c0f\u5df2\u51cf\u53bb\u4e00
i=0\u7684\u65f6\u5019\uff0c\u6700\u7ec8\u7684\u7ed3\u679c\u4e3a
8\uff0c1\uff0c2\uff0c3\uff0c6\uff0c4
i=1\u7684\u65f6\u5019\uff0c\u6700\u7ec8\u7684\u7ed3\u679c\u4e3a
8\uff0c6\uff0c1\uff0c2\uff0c3\uff0c4
i=2
8\uff0c6\uff0c4\uff0c1\uff0c2\uff0c3
i=3
\u2026<\/p>\n

\u4e09\u4e36\u611f\u8a00<\/h2>\n

\u5728\u8fd9\u91cc\u6211\u5c31\u4e0d\u4e00\u4e00\u5217\u4e3e\u4e86\uff0c\u6392\u5e8f\u7684\u65b9\u6cd5\u5f88\u591a\uff0c\u5192\u6ce1\u6392\u5e8f\u53ea\u662f\u4e07\u5343\u6392\u5e8f\u7684\u4e00\u79cd\u3002\u5728\u6b64\u5c0f\u94c1\u53ea\u8bb2\u89e3\u8fd9\u4e00\u79cd<\/p>\n

\u65f6\u5149\u603b\u662f\u5f88\u77ed\u6682\u7684\uff0c\u53c8\u5230\u4e86\u548c\u5927\u5bb6\u8bf4\u518d\u89c1\u7684\u65f6\u5019\u3002\u5b66\u4e60\u8fc7\u7a0b\u5f88\u67af\u71e5\uff0c\u4f46\u662f\u5b66\u5230\u4e86\uff0c\u5c31\u4f1a\u611f\u5230\u5f88\u5145\u8db3\u3002\u3002\u4ee5\u4e0a\u6587\u7ae0\uff0c\u5e0c\u671b\u5bf9\u5927\u5bb6\u6709\u5e2e\u52a9\u3002\u4e66\u5199\u4e0d\u6613\uff0c\u8bf7\u70b9\u4e2a\u8d5e\u5427\u3002\u6709\u6761\u4ef6\u7684\u8bdd\uff0c\u70b9\u4e2a\u5173\u6ce8\u3002<\/p>\n

\u6211\u662f\u5c0f\u94c1\uff0c\u4e00\u4e2a\u5b9e\u529b\u4e0e\u9017\u6bd4\u7684\u7ed3\u5408\u4f53\u2026<\/strong><\/em><\/p>\n","protected":false},"excerpt":{"rendered":"java\u7684\u5192\u6ce1\u6392\u5e8f\u6cd5**\u5927\u5bb6\u597d\uff0c\u6211\u662f\u5c0f\u94c1\uff0c\u4eca\u5929\u53c8\u662f\u5199bug\u7684\u4e00\u5929\u2026**\u4e00\u4e36\u4eca\u5929\u6211\u4eec\u6765\u8bb2\u8bb2java\u4e2d\u7684\u5192\u6ce1\u6392\u5e8f\u6cd5\uff08\u8001\u9e1f\u8bf7\u76f4\u63a5\u62f7\u8d70\u4e0b\u9762\u7684...","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[82],"tags":[],"_links":{"self":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/639"}],"collection":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/comments?post=639"}],"version-history":[{"count":0,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/639\/revisions"}],"wp:attachment":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/media?parent=639"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/categories?post=639"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/tags?post=639"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}