{"id":76,"date":"2024-09-07T15:19:54","date_gmt":"2024-09-07T07:19:54","guid":{"rendered":"http:\/\/www.xxinran.tech\/?p=76"},"modified":"2024-10-17T22:28:44","modified_gmt":"2024-10-17T14:28:44","slug":"02","status":"publish","type":"post","link":"https:\/\/www.xxinran.tech\/index.php\/2024\/09\/07\/02\/","title":{"rendered":"C\u8bed\u8a00\u5b9e\u73b0\u5192\u6ce1\u6392\u5e8f"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u5f15\u8a00<\/h2>\n\n\n\n<p>\u5192\u6ce1\u6392\u5e8f\u662f\u6211\u5728\u4e0a\u5927\u4e00\u5b66\u4e60C\u8bed\u8a00\u8fc7\u7a0b\u4e2d\u6388\u8bfe\u8001\u5e08\u7ed9\u6211\u4eec\u8bb2\u7684\u7b2c\u4e00\u4e2a\u7b97\u6cd5\uff0c\u4e5f\u662f\u6211\u5728\u7f16\u7a0b\u9053\u8def\u4e0a\u5b66\u4f1a\u7684\u7b2c\u4e00\u4e2a\u7b97\u6cd5\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u539f\u7406\u89e3\u91ca<\/h2>\n\n\n\n<p>\u5192\u6ce1\u6392\u5e8f\u5c31\u548c\u5b83\u7684\u540d\u5b57\u4e00\u6837\uff0c\u50cf\u6c34\u4e2d\u7684\u6c14\u6ce1\u4e00\u6837\u4ece\u6700\u5e95\u4e0b\u5f80\u4e0a\u5347\u3002\u8f83\u5c0f\u7684\u5143\u7d20\u4f1a\u9010\u6e10\u5411\u5e8f\u5217\u7684\u4e00\u7aef\u201c\u6f02\u6d6e\u201d\u6216\u201c\u5192\u6ce1\u201d\u8d77\u6765\uff0c\u800c\u8f83\u5927\u7684\u5143\u7d20\u5219\u6c89\u5230\u53e6\u4e00\u7aef\u3002\u6bcf\u4e00\u8f6e\u904d\u5386\u90fd\u4f1a\u786e\u4fdd\u81f3\u5c11\u6709\u4e00\u4e2a\u5143\u7d20\uff08\u901a\u5e38\u662f\u6700\u540e\u4e00\u4e2a\u672a\u6392\u5e8f\u7684\u5143\u7d20\uff09\u5230\u8fbe\u5176\u6700\u7ec8\u7684\u6b63\u786e\u4f4d\u7f6e\u3002<\/p>\n\n\n\n<p>\u5176\u57fa\u672c\u601d\u60f3\u662f\u91cd\u590d\u5730\u904d\u5386\u9700\u8981\u6392\u5e8f\u7684\u6570\u5217\uff0c\u6bcf\u6b21\u904d\u5386\u65f6\u901a\u8fc7\u4e24\u4e24\u6bd4\u8f83\u76f8\u90bb\u5143\u7d20\uff0c\u5982\u679c\u4ed6\u4eec\u7684\u987a\u5e8f\u9519\u8bef\uff08\u5373\u524d\u4e00\u4e2a\u6bd4\u540e\u4e00\u4e2a\u5927\u6216\u76f8\u53cd\uff09\uff0c\u5c31\u4ea4\u6362\u8fd9\u4e24\u4e2a\u5143\u7d20\u7684\u4f4d\u7f6e\u3002\u8fd9\u4e2a\u8fc7\u7a0b\u4f1a\u4e00\u76f4\u6301\u7eed\u5230\u6ca1\u6709\u66f4\u591a\u7684\u5143\u7d20\u9700\u8981\u4ea4\u6362\u4e3a\u6b62\uff0c\u4e5f\u5c31\u662f\u6570\u5217\u5df2\u7ecf\u6392\u5e8f\u5b8c\u6210\u3002<\/p>\n\n\n\n<p>\u9644\u4e00\u5f20\u539f\u7406\u56fe<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized is-style-default\"><img loading=\"lazy\" decoding=\"async\" width=\"2612\" height=\"1960\" src=\"http:\/\/www.xxinran.tech\/wp-content\/uploads\/2024\/09\/1725692597-2019120918451447-edited.png\" alt=\"\" class=\"wp-image-79\" style=\"width:712px;height:auto\" srcset=\"https:\/\/www.xxinran.tech\/wp-content\/uploads\/2024\/09\/1725692597-2019120918451447-edited.png 2612w, https:\/\/www.xxinran.tech\/wp-content\/uploads\/2024\/09\/1725692597-2019120918451447-edited-300x225.png 300w, https:\/\/www.xxinran.tech\/wp-content\/uploads\/2024\/09\/1725692597-2019120918451447-edited-1024x768.png 1024w, https:\/\/www.xxinran.tech\/wp-content\/uploads\/2024\/09\/1725692597-2019120918451447-edited-768x576.png 768w, https:\/\/www.xxinran.tech\/wp-content\/uploads\/2024\/09\/1725692597-2019120918451447-edited-1536x1153.png 1536w, https:\/\/www.xxinran.tech\/wp-content\/uploads\/2024\/09\/1725692597-2019120918451447-edited-2048x1537.png 2048w\" sizes=\"(max-width: 2612px) 100vw, 2612px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u57fa\u672c\u6b65\u9aa4<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u521d\u59cb\u5316<\/strong>\uff1a\u9009\u62e9\u4e00\u4e2a\u65b9\u5411\uff08\u5347\u5e8f\u6216\u964d\u5e8f\uff09\uff0c\u5e76\u4ece\u5e8f\u5217\u7684\u7b2c\u4e00\u4e2a\u5143\u7d20\u5f00\u59cb\u3002<\/li>\n\n\n\n<li><strong>\u6bd4\u8f83\u4e0e\u4ea4\u6362<\/strong>\uff1a\u6bd4\u8f83\u76f8\u90bb\u7684\u5143\u7d20\u3002\u5982\u679c\u7b2c\u4e00\u4e2a\u6bd4\u7b2c\u4e8c\u4e2a\u5927\uff08\u5bf9\u4e8e\u5347\u5e8f\u6392\u5e8f\uff09\uff0c\u5219\u4ea4\u6362\u5b83\u4eec\uff1b\u53cd\u4e4b\u4ea6\u7136\u3002<\/li>\n\n\n\n<li><strong>\u7ee7\u7eed\u904d\u5386<\/strong>\uff1a\u7ee7\u7eed\u5bf9\u6bcf\u4e00\u5bf9\u76f8\u90bb\u5143\u7d20\u6267\u884c\u6b65\u9aa42\uff0c\u76f4\u5230\u5217\u8868\u7684\u672b\u5c3e\u3002<\/li>\n\n\n\n<li><strong>\u91cd\u590d<\/strong>\uff1a\u91cd\u590d\u6b65\u9aa42\u548c3\uff0c\u4f46\u662f\u6bcf\u6b21\u904d\u5386\u90fd\u5ffd\u7565\u5df2\u6b63\u786e\u6392\u5e8f\u7684\u90e8\u5206\uff08\u901a\u5e38\u662f\u5e8f\u5217\u7684\u5c3e\u90e8\uff09\u3002<\/li>\n\n\n\n<li><strong>\u7ec8\u6b62\u6761\u4ef6<\/strong>\uff1a\u5f53\u6ca1\u6709\u66f4\u591a\u7684\u4ea4\u6362\u53d1\u751f\u65f6\uff0c\u6392\u5e8f\u5b8c\u6210<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">\u4ee3\u7801\u5b9e\u73b0<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;stdio.h&gt;\nint main() {\n\tint arr&#91;10];\n\tint temp;\n\tfor (int i = 0; i &lt; 10; i++) {\n\t\tscanf(\"%d\", &amp;arr&#91;i]);\n\t}\n\tfor (int i = 0; i &lt; 10; i++) {\n\t\tfor (int j = 0; j &lt; 9 - i; j++) {\n\t\t\tif (arr&#91;j] &gt; arr&#91;j + 1]) {\n\t\t\t\ttemp = arr&#91;j];         \n\t\t\t\tarr&#91;j] = arr&#91;j + 1];\n\t\t\t\tarr&#91;j + 1] = temp;\n\t\t\t}\n\t\t}\n\t}\n\tfor (int i = 0; i &lt; 10; i++) {\n\t\tprintf(\"%d\", arr&#91;i]);\n\t}\n\treturn 0;\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u6548\u679c<\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"487\" height=\"378\" src=\"http:\/\/www.xxinran.tech\/wp-content\/uploads\/2024\/09\/1725693233-bb7dded5e18665cee373a1c462ceb72.png\" alt=\"\" class=\"wp-image-81\" srcset=\"https:\/\/www.xxinran.tech\/wp-content\/uploads\/2024\/09\/1725693233-bb7dded5e18665cee373a1c462ceb72.png 487w, https:\/\/www.xxinran.tech\/wp-content\/uploads\/2024\/09\/1725693233-bb7dded5e18665cee373a1c462ceb72-300x233.png 300w\" sizes=\"(max-width: 487px) 100vw, 487px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Tips<\/h2>\n\n\n\n<p>\u5728\u4ee3\u7801\u4e2d\u7b2c\u4e8c\u5c42for\u5faa\u73af\u4e2d\u201dj&lt;9-i\"\u7684\u539f\u56e0\u662f\u5728\u6bcf\u8f6e\u904d\u5386\u4e2d\uff0c\u6700\u540e\u4e00\u4e2a\u5143\u7d20\uff08\u6216\u79f0\u5f53\u524d\u8f6e\u6b21\u7684\u6700\u540e\u4e00\u4e2a\u672a\u6392\u5e8f\u5143\u7d20\uff09\u4f1a\u88ab\u653e\u7f6e\u5230\u5b83\u5e94\u8be5\u5904\u4e8e\u7684\u6b63\u786e\u4f4d\u7f6e\u3002\u968f\u7740\u904d\u5386\u7684\u8fdb\u884c\uff0c\u6bcf\u4e00\u8f6e\u90fd\u4f1a\u5c06\u4e00\u4e2a\u5143\u7d20\u653e\u5230\u5b83\u7684\u6700\u7ec8\u4f4d\u7f6e\u4e0a\uff0c\u56e0\u6b64\u4e0b\u4e00\u8f6e\u5c31\u4e0d\u9700\u8981\u518d\u8003\u8651\u8fd9\u4e2a\u5143\u7d20\u4e86\u3002<\/p>\n\n\n\n<p>\u4ee5\u5347\u5e8f\u6392\u5e8f\u4e3a\u4f8b\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u7b2c\u4e00\u8f6e\uff1a\u9700\u8981\u8fdb\u884c&nbsp;<code>n-1<\/code>&nbsp;\u6b21\u6bd4\u8f83\uff0c\u5c06\u6700\u5927\u7684\u5143\u7d20\u79fb\u5230\u6570\u7ec4\u7684\u6700\u540e\u3002<\/li>\n\n\n\n<li>\u7b2c\u4e8c\u8f6e\uff1a\u9700\u8981\u8fdb\u884c&nbsp;<code>n-2<\/code>&nbsp;\u6b21\u6bd4\u8f83\uff0c\u5c06\u6b21\u5927\u7684\u5143\u7d20\u79fb\u5230\u5012\u6570\u7b2c\u4e8c\u4e2a\u4f4d\u7f6e\u3002<\/li>\n\n\n\n<li>\u7b2c\u4e09\u8f6e\uff1a\u9700\u8981\u8fdb\u884c&nbsp;<code>n-3<\/code>&nbsp;\u6b21\u6bd4\u8f83\uff0c\u5c06\u7b2c\u4e09\u5927\u7684\u5143\u7d20\u79fb\u5230\u5012\u6570\u7b2c\u4e09\u4e2a\u4f4d\u7f6e\u3002<\/li>\n\n\n\n<li>...<\/li>\n\n\n\n<li>\u6700\u540e\u4e00\u8f6e\uff1a\u9700\u8981\u8fdb\u884c&nbsp;<code>1<\/code>&nbsp;\u6b21\u6bd4\u8f83\uff0c\u5c06\u4ec5\u5269\u7684\u4e24\u4e2a\u5143\u7d20\u8fdb\u884c\u6bd4\u8f83\u5e76\u6392\u5e8f\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u603b\u7ed3\u6765\u8bf4\uff0c\u6bcf\u8f6e\u904d\u5386\u7684\u6bd4\u8f83\u6b21\u6570\u5982\u4e0b\u8868\u6240\u793a\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u8f6e\u6b21<\/th><th>\u6bd4\u8f83\u6b21\u6570<\/th><\/tr><\/thead><tbody><tr><td>1<\/td><td>n - 1<\/td><\/tr><tr><td>2<\/td><td>n - 2<\/td><\/tr><tr><td>...<\/td><td>...<\/td><\/tr><tr><td>n-1<\/td><td>1<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u603b\u7ed3<\/h2>\n\n\n\n<p>\u5192\u6ce1\u6392\u5e8f\u867d\u7136\u7b80\u5355\u6613\u61c2\uff0c\u4f46\u7531\u4e8e\u5176\u8f83\u9ad8\u7684\u65f6\u95f4\u590d\u6742\u5ea6\uff0c\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\u901a\u5e38\u53ea\u9002\u7528\u4e8e\u5c0f\u578b\u6570\u636e\u96c6\u6216\u6559\u5b66\u6f14\u793a\u3002\u5bf9\u4e8e\u5927\u89c4\u6a21\u6570\u636e\u7684\u6392\u5e8f\uff0c\u66f4\u9ad8\u6548\u7684\u7b97\u6cd5\u5982\u5feb\u901f\u6392\u5e8f\u3001\u5f52\u5e76\u6392\u5e8f\u7b49\u901a\u5e38\u66f4\u52a0\u5408\u9002\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5f15\u8a00 \u5192\u6ce1\u6392\u5e8f\u662f\u6211\u5728\u4e0a\u5927\u4e00\u5b66\u4e60C\u8bed\u8a00\u8fc7\u7a0b\u4e2d\u6388\u8bfe\u8001\u5e08\u7ed9\u6211\u4eec\u8bb2\u7684\u7b2c\u4e00\u4e2a\u7b97\u6cd5\uff0c\u4e5f\u662f\u6211\u5728\u7f16\u7a0b\u9053\u8def\u4e0a\u5b66\u4f1a\u7684\u7b2c\u4e00\u4e2a\u7b97\u6cd5\u3002 \u539f\u7406\u89e3\u91ca \u5192\u6ce1\u6392\u5e8f\u5c31 &#8230;<\/p>\n","protected":false},"author":1,"featured_media":84,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,9],"tags":[11,10],"class_list":["post-76","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tech","category-9","tag-c","tag-10"],"_links":{"self":[{"href":"https:\/\/www.xxinran.tech\/index.php\/wp-json\/wp\/v2\/posts\/76"}],"collection":[{"href":"https:\/\/www.xxinran.tech\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xxinran.tech\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xxinran.tech\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xxinran.tech\/index.php\/wp-json\/wp\/v2\/comments?post=76"}],"version-history":[{"count":3,"href":"https:\/\/www.xxinran.tech\/index.php\/wp-json\/wp\/v2\/posts\/76\/revisions"}],"predecessor-version":[{"id":247,"href":"https:\/\/www.xxinran.tech\/index.php\/wp-json\/wp\/v2\/posts\/76\/revisions\/247"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.xxinran.tech\/index.php\/wp-json\/wp\/v2\/media\/84"}],"wp:attachment":[{"href":"https:\/\/www.xxinran.tech\/index.php\/wp-json\/wp\/v2\/media?parent=76"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xxinran.tech\/index.php\/wp-json\/wp\/v2\/categories?post=76"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xxinran.tech\/index.php\/wp-json\/wp\/v2\/tags?post=76"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}