{"id":48822,"date":"2024-12-02T17:28:28","date_gmt":"2024-12-02T09:28:28","guid":{"rendered":"https:\/\/fwq.ai\/blog\/48822\/"},"modified":"2024-12-02T17:28:28","modified_gmt":"2024-12-02T09:28:28","slug":"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8%e7%a9%ba%e6%a0%bc%e5%a1%ab%e5%85%85-javascript-%e4%b8%ad%e7%9a%84%e5%ad%97%e7%ac%a6%e4%b8%b2%e6%88%96%e6%95%b0%e7%bb%84%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/48822\/","title":{"rendered":"\u5982\u4f55\u4f7f\u7528\u7a7a\u683c\u586b\u5145 JavaScript \u4e2d\u7684\u5b57\u7b26\u4e32\u6216\u6570\u7ec4\uff1f"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>\u5982\u4f55\u4f7f\u7528\u7a7a\u683c\u586b\u5145 JavaScript \u4e2d\u7684\u5b57\u7b26\u4e32\u6216\u6570\u7ec4\uff1f<\/h1>\n<p>\u5728\u6587\u7ae0\u5b9e\u6218\u5f00\u53d1\u7684\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u7ecf\u5e38\u4f1a\u9047\u5230\u4e00\u4e9b\u8fd9\u6837\u90a3\u6837\u7684\u95ee\u9898\uff0c\u7136\u540e\u8981\u5361\u597d\u534a\u5929\uff0c\u7b49\u95ee\u9898\u89e3\u51b3\u4e86\u624d\u53d1\u73b0\u539f\u6765\u4e00\u4e9b\u7ec6\u8282\u77e5\u8bc6\u70b9\u8fd8\u662f\u6ca1\u6709\u638c\u63e1\u597d\u3002\u4eca\u5929\u7c73\u4e91\u5c31\u6574\u7406\u5206\u4eab\u300a\u5982\u4f55\u4f7f\u7528\u7a7a\u683c\u586b\u5145 JavaScript \u4e2d\u7684\u5b57\u7b26\u4e32\u6216\u6570\u7ec4\uff1f\u300b\uff0c\u804a\u804a\uff0c\u5e0c\u671b\u53ef\u4ee5\u5e2e\u52a9\u5230\u6b63\u5728\u52aa\u529b\u8d5a\u94b1\u7684\u4f60\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241101\/1730435258672458ba4dc14.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u4f7f\u7528\u7a7a\u683c\u586b\u5145 JavaScript \u4e2d\u7684\u5b57\u7b26\u4e32\u6216\u6570\u7ec4\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u4f7f\u7528\u7a7a\u683c\u586b\u5145 JavaScript \u4e2d\u7684\u5b57\u7b26\u4e32\u6216\u6570\u7ec4\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5728 javascript \u4e2d\u4f7f\u7528\u7a7a\u683c\u586b\u5145\u5b57\u7b26\u4e32\u6216\u6570\u7ec4<\/strong><\/p>\n<p>\u5728 javascript \u4e2d\uff0c\u5411\u5b57\u7b26\u4e32\u6216\u6570\u7ec4\u4e2d\u6dfb\u52a0\u7a7a\u683c\u9700\u8981\u4f7f\u7528\u7279\u5b9a\u7684\u65b9\u6cd5\u548c\u6280\u5de7\u3002\u672c\u6587\u5c06\u6839\u636e\u793a\u4f8b\u548c\u7b54\u6848\u6765\u4ecb\u7ecd\u5982\u4f55\u5728 javascript \u4e2d\u6267\u884c\u6b64\u64cd\u4f5c\u3002<\/p>\n<p><strong>\u793a\u4f8b\u4ee3\u7801<\/strong><\/p>\n<p>\u7ed9\u5b9a\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre>function jin($flow) {\n  $arr1 = array('.');\n  $b = '';\n  $b = str_pad($b, 5, \".\");\n  $arr2 = array('*');\n  $k = '';\n  for ($i=1; $i&lt;=$flow; $i++) {\n    $b = substr($b, 1);\n    array_push($arr1, $b);\n    echo $arr1[$i];\n    $k = str_pad($k, 2*$i-1,'*');\n    array_push($arr2, $k);\n    echo $arr2[$i].\"&lt;br \/&gt;\";\n  }\n}\n\njin(5);<\/pre>\n<p><strong>\u95ee\u9898<\/strong><\/p>\n<p>\u5982\u4f55\u4f7f\u7528\u7a7a\u683c\u586b\u5145\u5b57\u7b26\u4e32\u6216\u6570\u7ec4\uff1f<\/p>\n<p><strong>\u7b54\u6848<\/strong><\/p>\n<p>\u53ef\u4ee5\u4f7f\u7528 replace() \u65b9\u6cd5\u6765\u5c06\u5b57\u7b26\u4e32\u4e2d\u7684\u67d0\u4e2a\u5b57\u7b26\u66ff\u6362\u4e3a\u7a7a\u683c\uff0c\u65b9\u6cd5\u5982\u4e0b\uff1a<\/p>\n<pre>string.replace(\".\",\" \");<\/pre>\n<p>\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u5728 javascript \u4e2d\uff0c\u5b57\u7b26\u4e32\u548c\u6570\u7ec4\u7c7b\u578b\u4e0d\u540c\u3002\u6570\u7ec4\u662f\u4e00\u79cd\u6709\u5e8f\u7684\u5143\u7d20\u96c6\u5408\uff0c\u800c\u5b57\u7b26\u4e32\u662f\u4e00\u79cd\u5b57\u7b26\u5e8f\u5217\u3002\u56e0\u6b64\uff0cstr_pad() \u65b9\u6cd5\u4e0d\u9002\u7528\u4e8e\u6570\u7ec4\u3002<\/p>\n<p>\u597d\u4e86\uff0c\u672c\u6587\u5230\u6b64\u7ed3\u675f\uff0c\u5e26\u5927\u5bb6\u4e86\u89e3\u4e86\u300a\u5982\u4f55\u4f7f\u7528\u7a7a\u683c\u586b\u5145 JavaScript \u4e2d\u7684\u5b57\u7b26\u4e32\u6216\u6570\u7ec4\uff1f\u300b\uff0c\u5e0c\u671b\u672c\u6587\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\uff01\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff0c\u7ed9\u5927\u5bb6\u5206\u4eab\u66f4\u591a\u6587\u7ae0\u77e5\u8bc6\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u4f7f\u7528\u7a7a\u683c\u586b\u5145 JavaScript \u4e2d\u7684\u5b57\u7b26\u4e32\u6216\u6570\u7ec4\uff1f \u5728\u6587\u7ae0\u5b9e\u6218\u5f00\u53d1\u7684\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u7ecf\u5e38\u4f1a\u9047\u5230\u4e00\u4e9b\u8fd9\u6837\u90a3\u6837\u7684\u95ee\u9898\uff0c\u7136\u540e\u8981\u5361\u597d\u534a\u5929\uff0c\u7b49\u95ee\u9898\u89e3\u51b3\u4e86\u624d\u53d1\u73b0\u539f\u6765\u4e00\u4e9b\u7ec6\u8282\u77e5\u8bc6\u70b9\u8fd8\u662f\u6ca1\u6709\u638c\u63e1\u597d\u3002\u4eca\u5929\u7c73\u4e91\u5c31\u6574\u7406\u5206\u4eab\u300a\u5982\u4f55\u4f7f\u7528\u7a7a\u683c\u586b\u5145 JavaScript \u4e2d\u7684\u5b57\u7b26\u4e32\u6216\u6570\u7ec4\uff1f\u300b\uff0c\u804a\u804a\uff0c\u5e0c\u671b\u53ef\u4ee5\u5e2e\u52a9\u5230\u6b63\u5728\u52aa\u529b\u8d5a\u94b1\u7684\u4f60\u3002 \u5982\u4f55\u5728 javascript \u4e2d\u4f7f\u7528\u7a7a\u683c\u586b\u5145\u5b57\u7b26\u4e32\u6216\u6570\u7ec4 \u5728 javascript \u4e2d\uff0c\u5411\u5b57\u7b26\u4e32\u6216\u6570\u7ec4\u4e2d\u6dfb\u52a0\u7a7a\u683c\u9700\u8981\u4f7f\u7528\u7279\u5b9a\u7684\u65b9\u6cd5\u548c\u6280\u5de7\u3002\u672c\u6587\u5c06\u6839\u636e\u793a\u4f8b\u548c\u7b54\u6848\u6765\u4ecb\u7ecd\u5982\u4f55\u5728 javascript \u4e2d\u6267\u884c\u6b64\u64cd\u4f5c\u3002 \u793a\u4f8b\u4ee3\u7801 \u7ed9\u5b9a\u4ee5\u4e0b\u4ee3\u7801\uff1a function jin($flow) { $arr1 = array(&#8216;.&#8217;); $b = &#8221;; $b = str_pad($b, 5, &#8220;.&#8221;); $arr2 = array(&#8216;*&#8217;); $k = &#8221;; for ($i=1; $i&lt;=$flow; $i++) { $b = substr($b, 1); array_push($arr1, $b); echo $arr1[$i]; $k = str_pad($k, 2*$i-1,&#8217;*&#8217;); array_push($arr2, $k); [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-48822","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/48822","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=48822"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/48822\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=48822"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=48822"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=48822"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}