{"id":204380,"date":"2025-05-29T08:54:22","date_gmt":"2025-05-29T00:54:22","guid":{"rendered":"https:\/\/server.hk\/cnblog\/204380\/"},"modified":"2025-05-29T08:54:22","modified_gmt":"2025-05-29T00:54:22","slug":"%e5%a6%82%e4%bd%95%e5%b0%86%e5%b5%8c%e5%a5%97%e5%88%97%e8%a1%a8%e4%b8%ad%e5%90%84%e4%b8%aa%e5%ad%90%e5%88%97%e8%a1%a8%e6%89%80%e6%9c%89%e5%85%83%e7%b4%a0%e7%bb%84%e5%90%88%e6%88%90%e5%ad%97%e7%ac%a6","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/204380\/","title":{"rendered":"\u5982\u4f55\u5c06\u5d4c\u5957\u5217\u8868\u4e2d\u5404\u4e2a\u5b50\u5217\u8868\u6240\u6709\u5143\u7d20\u7ec4\u5408\u6210\u5b57\u7b26\u4e32\uff0c\u5e76\u6309\u987a\u5e8f\u8f93\u51fa\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>\u5982\u4f55\u5c06\u5d4c\u5957\u5217\u8868\u4e2d\u5404\u4e2a\u5b50\u5217\u8868\u6240\u6709\u5143\u7d20\u7ec4\u5408\u6210\u5b57\u7b26\u4e32\uff0c\u5e76\u6309\u987a\u5e8f\u8f93\u51fa\uff1f<\/h1>\n<p>\u672c\u7bc7\u6587\u7ae0\u7ed9\u5927\u5bb6\u5206\u4eab\u300a\u5982\u4f55\u5c06\u5d4c\u5957\u5217\u8868\u4e2d\u5404\u4e2a\u5b50\u5217\u8868\u6240\u6709\u5143\u7d20\u7ec4\u5408\u6210\u5b57\u7b26\u4e32\uff0c\u5e76\u6309\u987a\u5e8f\u8f93\u51fa\uff1f\u300b\uff0c\u8986\u76d6\u4e86\u6587\u7ae0\u7684\u5e38\u89c1\u57fa\u7840\u77e5\u8bc6\uff0c\u5176\u5b9e\u4e00\u4e2a\u8bed\u8a00\u7684\u5168\u90e8\u77e5\u8bc6\u70b9\u4e00\u7bc7\u6587\u7ae0\u662f\u4e0d\u53ef\u80fd\u8bf4\u5b8c\u7684\uff0c\u4f46\u5e0c\u671b\u901a\u8fc7\u8fd9\u4e9b\u95ee\u9898\uff0c\u8ba9\u8bfb\u8005\u5bf9\u81ea\u5df1\u7684\u638c\u63e1\u7a0b\u5ea6\u6709\u4e00\u5b9a\u7684\u8ba4\u8bc6(B \u6570)\uff0c\u4ece\u800c\u5f25\u8865\u81ea\u5df1\u7684\u4e0d\u8db3\uff0c\u66f4\u597d\u7684\u638c\u63e1\u5b83\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241106\/1730862036672adbd4bdba0.jpg\" class=\"aligncenter\"><\/p>\n<p><strong>\u6309\u987a\u5e8f\u6392\u5217\u7ec4\u5408\u8f93\u51fa\u5b57\u7b26\u4e32<\/strong><\/p>\n<p><strong>\u95ee\u9898\uff1a<\/strong><\/p>\n<p>\u5982\u4f55\u5c06\u5d4c\u5957\u5217\u8868\u4e2d\u7b2c\u4e00\u4e2a\u5217\u8868\u4e2d\u7684\u7b2c\u4e00\u4e2a\u5143\u7d20\u5230\u6700\u540e\u4e00\u4e2a\u5217\u8868\u4e2d\u7684\u6700\u540e\u4e00\u4e2a\u5143\u7d20\uff0c\u6309\u987a\u5e8f\u904d\u5386\u5e76\u7ec4\u5408\u6210\u5b57\u7b26\u4e32\u8f93\u51fa\uff1f<\/p>\n<p><strong>\u89e3\u7b54\uff1a<\/strong><\/p>\n<ol>\n<li>\n<p><strong>\u5206\u5272\u5217\u8868\uff1a<\/strong><\/p>\n<p>\u5c06\u5d4c\u5957\u5217\u8868\u62c6\u5206\u4e3a\u591a\u53d8\u91cf\uff0c\u5206\u522b\u4e3a\uff1a<\/p>\n<pre>a0 = strlst[0]\na1 = strlst[1]\na2 = strlst[2]\na3 = strlst[3]\na4 = strlst[4]<\/pre>\n<\/li>\n<li>\n<p><strong>\u8ba1\u7b97\u5143\u7d20\u6570\u91cf\uff1a<\/strong><\/p>\n<p>\u8ba1\u7b97\u6bcf\u4e2a\u5206\u5272\u51fa\u7684\u53d8\u91cf\u4e2d\u7684\u5b57\u7b26\u4e32\u6570\u91cf\uff1a<\/p>\n<pre>l0 = len(a0)\nl1 = len(a1)\nl2 = len(a2)\nl3 = len(a3)\nl4 = len(a4)<\/pre>\n<\/li>\n<li>\n<p><strong>\u8ba1\u6570\u5668\uff1a<\/strong><\/p>\n<p>\u521d\u59cb\u5316\u8ba1\u6570\u5668\u5e76\u5c06\u8ba1\u6570\u9650\u5236\u4e3a\u5168\u90e8\u5143\u7d20\u7684\u7ec4\u5408\u6570\u91cf\uff1a<\/p>\n<pre>n0 = 0\nn1 = 0\nn2 = 0\nn3 = 0\nn4 = 0\n\nsum = l0 * l1 * l2 * l3 * l4\ncount = 0<\/pre>\n<\/li>\n<li>\n<p><strong>\u904d\u5386\u73af\uff1a<\/strong><\/p>\n<p>\u8fdb\u5165 while \u5faa\u73af\uff0c\u6267\u884c\u4ee5\u4e0b\u6b65\u9aa4\uff0c\u76f4\u5230 count \u8fbe\u5230\u5176\u9650\u5236\uff1a<\/p>\n<pre>while count &lt; sum:\n    # \u4f7f\u7528\u6ee1\u4f4d\u8fdb\u4e00\u7684\u7b97\u6cd5\u904d\u5386\u8ba1\u6570\u5668\n    ...\n\n    # \u8f93\u51fa\u6bb5\uff0c\u6309\u9700\u6dfb\u52a0\u7f29\u8fdb\u5e76\u8fde\u63a5\u5b57\u7b26\u4e32\n    ...\n\n    # \u66f4\u65b0\u8ba1\u6570\u5668\u548c count\n    ...<\/pre>\n<\/li>\n<li>\n<p><strong>\u8f93\u51fa\uff1a<\/strong><\/p>\n<p>\u5faa\u73af\u5b8c\u6210\u540e\uff0c\u5c06\u7ec4\u5408\u7684\u5b57\u7b26\u4e32\u8f93\u51fa\u5230\u63a7\u5236\u53f0\u3002<\/p>\n<\/li>\n<\/ol>\n<p><strong>\u793a\u4f8b\u4ee3\u7801\uff1a<\/strong><\/p>\n<p>\u4ee5\u4e0b\u4ee3\u7801\u6839\u636e\u95ee\u9898\u63d0\u4f9b\u4e86\u793a\u4f8b\u8f93\u51fa\uff1a<\/p>\n<pre>strlst = [['cmd1'],['opt1-1','opt1-2',''],['opt1-3'],['opt1-4',''],['opt1-5','']]\n\na0 = strlst[0]\na1 = strlst[1]\na2 = strlst[2]\na3 = strlst[3]\na4 = strlst[4]\n\nl0 = len(a0)\nl1 = len(a1)\nl2 = len(a2)\nl3 = len(a3)\nl4 = len(a4)\n\nn0 = 0\nn1 = 0\nn2 = 0\nn3 = 0\nn4 = 0\n\nsum = l0 * l1 * l2 * l3 * l4\ncount = 0\n\nwhile count &lt; sum:\n    if n4 &gt;= l4:\n        n4 = 0\n        n3 += 1\n        if n3 &gt;= l3:\n            n3 = 0\n            n2 += 1\n            if n2 &gt;= l2:\n                n2 = 0\n                n1 += 1\n                if n1 &gt;= l1:\n                    n1 = 0\n                    n0 += 1\n                    if n0 &gt;= l0:\n                        n0 = 0\n\n    needoutput = ''\n    if a0[n0] != '':\n        needoutput = needoutput + a0[n0] + '\\t'\n    else:\n        needoutput = needoutput + a0[n0]\n\n    if a1[n1] != '':\n        needoutput = needoutput + a1[n1] + '\\t'\n    else:\n        needoutput = needoutput + a1[n1]\n\n    if a2[n2] != '':\n        needoutput = needoutput + a2[n2] + '\\t'\n    else:\n        needoutput = needoutput + a2[n2]\n\n    if a3[n3] != '':\n        needoutput = needoutput + a3[n3] + '\\t'\n    else:\n        needoutput = needoutput + a3[n3]\n\n    if a4[n4] != '':\n        needoutput = needoutput + a4[n4]\n\n    needoutput = needoutput.expandtabs(7)\n    print(needoutput)\n\n    n4 += 1\n    count += 1<\/pre>\n<p><strong>\u8f93\u51fa\uff1a<\/strong><\/p>\n<pre>cmd1    opt1-1    opt1-3    opt1-4    opt1-5\ncmd1    opt1-1    opt1-3    opt1-4\ncmd1    opt1-1    opt1-3    opt1-5\ncmd1    opt1-1    opt1-3\ncmd1    opt1-2    opt1-3    opt1-4    opt1-5\ncmd1    opt1-2    opt1-3    opt1-4\ncmd1    opt1-2    opt1-3    opt1-5\ncmd1    opt1-2    opt1-3\ncmd1    opt1-3    opt1-4    opt1-5\ncmd1    opt1-3    opt1-4\ncmd1    opt1-3    opt1-5\ncmd1    opt1-3<\/pre>\n<p>\u5230\u8fd9\u91cc\uff0c\u6211\u4eec\u4e5f\u5c31\u8bb2\u5b8c\u4e86\u300a\u5982\u4f55\u5c06\u5d4c\u5957\u5217\u8868\u4e2d\u5404\u4e2a\u5b50\u5217\u8868\u6240\u6709\u5143\u7d20\u7ec4\u5408\u6210\u5b57\u7b26\u4e32\uff0c\u5e76\u6309\u987a\u5e8f\u8f93\u51fa\uff1f\u300b\u7684\u5185\u5bb9\u4e86\u3002\u4e2a\u4eba\u8ba4\u4e3a\uff0c\u57fa\u7840\u77e5\u8bc6\u7684\u5b66\u4e60\u548c\u5de9\u56fa\uff0c\u662f\u4e3a\u4e86\u66f4\u597d\u7684\u5c06\u5176\u8fd0\u7528\u5230\u9879\u76ee\u4e2d\uff0c\u6b22\u8fce\u5173\u6ce8\u516c\u4f17\u53f7\uff0c\u5e26\u4f60\u4e86\u89e3\u66f4\u591a\u5173\u4e8e\u7684\u77e5\u8bc6\u70b9\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u5c06\u5d4c\u5957\u5217\u8868\u4e2d\u5404\u4e2a\u5b50\u5217\u8868\u6240\u6709\u5143&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4925],"tags":[],"class_list":["post-204380","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/204380","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=204380"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/204380\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=204380"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=204380"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=204380"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}