{"id":1454,"date":"2015-02-21T22:22:25","date_gmt":"2015-02-21T14:22:25","guid":{"rendered":"http:\/\/boweihe.me\/?p=1454"},"modified":"2015-02-21T22:22:25","modified_gmt":"2015-02-21T14:22:25","slug":"%e7%bb%84%e5%90%88-%e9%80%92%e5%bd%92","status":"publish","type":"post","link":"https:\/\/dayandcarrot.space\/?p=1454","title":{"rendered":"\u7ec4\u5408 \u9012\u5f52"},"content":{"rendered":"<p>\u8352\u5e9f\u8ba1\u7b97\u673a\u592a\u4e45\u4e86\uff0c\u4ee5\u81f3\u4e8e\u8fd9\u4e48\u7b80\u5355\u4e00\u4e2a\u95ee\u9898\u60f3\u4e86\u6211\u5927\u534a\u5929\uff0c\u5176\u5b9e\u5c31\u662f\u6570\u7ec4\u6c42\u7ec4\u5408\u8f93\u51fa\u7684\u65b9\u6cd5\uff0c\u5199\u4e0b\u6b64\u65e5\u5fd7\u63d0\u9192\u81ea\u5df1\u4e0d\u80fd\u5fd8\u4e86\u8001\u672c!<br \/>\n\u9898\u76ee\u7684\u8bdd\u5927\u6982\u53ef\u4ee5\u8fd9\u6837\u8868\u8ff0<\/p>\n<blockquote><p>\u7ed9\u51fa\u4e00\u4e2a\u6570\u636eA={a_0,a_1,a_2\u2026a_n}(\u5176\u4e2dn\u53ef\u53d8)\uff0c\u6253\u5370\u51fa\u8be5\u6570\u503c\u5143\u7d20\u7684\u6240\u6709\u7ec4\u5408<\/p><\/blockquote>\n<p>\u9700\u8981\u4f7f\u7528\u9012\u5f52\u7684\u65b9\u6cd5\u89e3\u51b3\u6bd4\u8f83\u597d\uff0c\u5206\u800c\u6cbb\u4e4b<\/p>\n<blockquote><p>\u7ed9\u4e00\u5927\u56e2\u6570\u636e{a0,a1, a2, &#8230;, an}\uff1a<br \/>\n1. \u5982\u679c\u5c31\u5269\u4e00\u4e2a\u5143\u7d20\u7684\u8bdd\uff0c\u6211\u5c31\u8f93\u51fa\u5b83\uff0c\u7ed3\u675f\uff1b<br \/>\n2.\u4e0d\u8f93\u51faa0\uff0c\u628a\u9664\u4e86\u6211\u4e4b\u5916\u7684\u4f59\u4e0b\u4e00\u56e2\u4ea4\u7531\u9012\u5f52\u5904\u7406\uff1b<br \/>\n3.\u8981\u8f93\u51faa0\u81ea\u5df1\uff0c\u7136\u540e\u4f59\u4e0b\u4e00\u56e2\u4ea4\u7531\u9012\u5f52\u5904\u7406\uff1b<\/p><\/blockquote>\n<p>\u5176\u4e2dcase 3\u91cc\u9762\u9700\u8981\u6ce8\u610f\u4e0b\u4e00\u4e2a\u9012\u5f52\u8981\u8bb0\u4f4fa0\u662f\u8981\u8f93\u51fa\u7684\uff0c\u6240\u4ee5\u5b9e\u8df5\u8d77\u6765\u5c31\u662f\u5e26\u4e86\u4e2a\u524d\u7f00\u4e00\u6837\u7684\u4e1c\u897f\u8bb0\u4f4f\u3002\u611f\u89c9\u8fd9\u79cd\u6392\u5217\u7ec4\u5408\u7684\u95ee\u9898\u5e94\u8be5\u4e5f\u53ef\u4ee5\u7528\u6808\u6765\u89e3\u51b3\uff0c\u4f46\u5f52\u6839\u7ed3\u5e95\u8fd8\u662f\u5206\u6cbb\u3002<br \/>\n\u7528Python\u968f\u610f\u5199\u4e86\u4e00\u4e2a\uff1a<\/p>\n<pre class=\"lang:python decode:true\"># coding:utf-8\ndef foo(inary, appendix=''):\n    if len(inary) == 0:\n        return\n    #Case 0\n    print appendix + str(inary[0])\n    if len(inary) &lt; 2:\n        return\n    #Case 1\n    foo(inary[1:], appendix)\n    #Case 2\n    #print str(inary[0]),\n    foo(inary[1:], appendix+str(inary[0]))<\/pre>\n<p>\u6d4b\u8bd5\u8f93\u51fa\uff1a<\/p>\n<pre class=\"lang:default decode:true \">&gt;&gt;&gt; foo([1, 2, 3, 4])\n1\n2\n3\n4\n34\n23\n24\n234\n12\n13\n14\n134\n123\n124\n1234<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8352\u5e9f\u8ba1\u7b97\u673a\u592a\u4e45\u4e86\uff0c\u4ee5\u81f3\u4e8e\u8fd9\u4e48\u7b80\u5355\u4e00\u4e2a\u95ee\u9898\u60f3\u4e86\u6211\u5927\u534a\u5929\uff0c\u5176\u5b9e\u5c31\u662f\u6570\u7ec4\u6c42\u7ec4\u5408\u8f93\u51fa\u7684\u65b9\u6cd5\uff0c\u5199\u4e0b\u6b64\u65e5\u5fd7\u63d0\u9192\u81ea\u5df1\u4e0d\u80fd\u5fd8\u4e86\u8001\u672c! \u9898\u76ee\u7684\u8bdd\u5927\u6982\u53ef\u4ee5\u8fd9\u6837\u8868\u8ff0 \u7ed9\u51fa\u4e00\u4e2a\u6570\u636eA={a_0,a_1,a_2\u2026a_n}(\u5176\u4e2dn\u53ef\u53d8)\uff0c\u6253\u5370\u51fa\u8be5\u6570\u503c\u5143\u7d20\u7684\u6240\u6709\u7ec4\u5408 \u9700\u8981\u4f7f\u7528\u9012\u5f52\u7684\u65b9\u6cd5\u89e3\u51b3\u6bd4\u8f83\u597d\uff0c\u5206\u800c\u6cbb\u4e4b \u7ed9\u4e00\u5927\u56e2\u6570\u636e{a0,a1, a2, &#8230;, an}\uff1a 1. \u5982\u679c\u5c31\u5269\u4e00\u4e2a\u5143\u7d20\u7684\u8bdd\uff0c\u6211\u5c31\u8f93\u51fa\u5b83\uff0c\u7ed3\u675f\uff1b 2.\u4e0d\u8f93\u51faa0\uff0c\u628a\u9664\u4e86\u6211\u4e4b\u5916\u7684\u4f59\u4e0b\u4e00\u56e2\u4ea4\u7531\u9012\u5f52\u5904\u7406\uff1b 3.\u8981\u8f93\u51faa0\u81ea\u5df1\uff0c\u7136\u540e\u4f59\u4e0b\u4e00\u56e2\u4ea4\u7531\u9012\u5f52\u5904\u7406\uff1b \u5176\u4e2dcase 3\u91cc\u9762\u9700\u8981\u6ce8\u610f\u4e0b\u4e00\u4e2a\u9012\u5f52\u8981\u8bb0\u4f4fa0\u662f\u8981\u8f93\u51fa\u7684\uff0c\u6240\u4ee5\u5b9e\u8df5\u8d77\u6765\u5c31\u662f\u5e26\u4e86\u4e2a\u524d\u7f00\u4e00\u6837\u7684\u4e1c\u897f\u8bb0\u4f4f\u3002\u611f\u89c9\u8fd9\u79cd\u6392\u5217\u7ec4\u5408\u7684\u95ee\u9898\u5e94\u8be5\u4e5f\u53ef\u4ee5\u7528\u6808\u6765\u89e3\u51b3\uff0c\u4f46\u5f52\u6839\u7ed3\u5e95\u8fd8\u662f\u5206\u6cbb\u3002 \u7528Python\u968f\u610f\u5199\u4e86\u4e00\u4e2a\uff1a # coding:utf-8 def foo(inary, appendix=&#8221;): if len(inary) == 0: return #Case 0 print appendix + str(inary[0]) if len(inary) &lt; 2: return #Case 1 foo(inary[1:], appendix) #Case 2 #print str(inary[0]), foo(inary[1:], appendix+str(inary[0])) \u6d4b\u8bd5\u8f93\u51fa\uff1a &gt;&gt;&gt; foo([1, 2, 3, 4]) 1 2 3 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[89,185],"class_list":["post-1454","post","type-post","status-publish","format-standard","hentry","category-study","tag-python","tag-185"],"_links":{"self":[{"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/posts\/1454","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1454"}],"version-history":[{"count":0,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/posts\/1454\/revisions"}],"wp:attachment":[{"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1454"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1454"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1454"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}