{"id":311692,"date":"2024-05-20T22:20:57","date_gmt":"2024-05-20T14:20:57","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/311692.html"},"modified":"2024-05-20T22:21:20","modified_gmt":"2024-05-20T14:21:20","slug":"c-%e8%af%ad%e8%a8%80%e7%bc%96%e7%a8%8b%e4%bb%a3%e7%a0%81%e6%80%8e%e4%b9%88%e5%be%aa%e7%8e%af%e6%89%93%e5%8d%b0%e6%98%9f%e5%8f%b7%e5%9b%be%e5%bd%a2-2","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/311692.html","title":{"rendered":"C \u8bed\u8a00\u7f16\u7a0b\u4ee3\u7801\u600e\u4e48\u5faa\u73af\u6253\u5370\u661f\u53f7\u56fe\u5f62"},"content":{"rendered":"<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/26232345\/5b7f566d-20ff-4c8d-97de-b75bc015b045.webp\" alt=\"C \u8bed\u8a00\u7f16\u7a0b\u4ee3\u7801\u600e\u4e48\u5faa\u73af\u6253\u5370\u661f\u53f7\u56fe\u5f62\" \/><\/p>\n<p><p>\u5728C\u8bed\u8a00\u7f16\u7a0b\u4e2d\uff0c\u8981\u5faa\u73af\u6253\u5370\u661f\u53f7\u56fe\u5f62\uff0c\u53ef\u901a\u8fc7\u4f7f\u7528\u5d4c\u5957\u7684<code>for<\/code>\u5faa\u73af\u6765\u5b9e\u73b0\u3001<strong>\u9010\u884c\u6253\u5370\u661f\u53f7<\/strong>\u3001\u63a7\u5236\u884c\u5217\u7684\u661f\u53f7\u6570\u91cf\u4e0e\u6392\u5217\u3001\u8c03\u8282\u5185\u5916\u5faa\u73af\u4ee5\u6784\u9020\u4e0d\u540c\u56fe\u5f62\u3002\u4e00\u4e2a\u7b80\u5355\u7684\u6b63\u65b9\u5f62\u661f\u53f7\u56fe\u7684\u6e90\u4ee3\u7801\u4f8b\u5b50\u662f\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-c\">#include &lt;stdio.h&gt;<\/p>\n<p>int m<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>n() {<\/p>\n<p>    int i, j;<\/p>\n<p>    int n = 5; \/\/ \u661f\u53f7\u56fe\u5f62\u7684\u5927\u5c0f\uff0c\u53ef\u6839\u636e\u9700\u8981\u4fee\u6539<\/p>\n<p>    for(i = 0; i &lt; n; i++) {<\/p>\n<p>        for(j = 0; j &lt; n; j++) {<\/p>\n<p>            printf(&quot;* &quot;);<\/p>\n<p>        }<\/p>\n<p>        printf(&quot;\\n&quot;);<\/p>\n<p>    }<\/p>\n<p>    return 0;<\/p>\n<p>}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u6bb5\u4ee3\u7801\u4e2d\uff0c\u5916\u5c42<code>for<\/code>\u5faa\u73af\u8d1f\u8d23\u63a7\u5236\u884c\u6570\uff0c\u5185\u5c42<code>for<\/code>\u5faa\u73af\u8d1f\u8d23\u63a7\u5236\u6bcf\u4e00\u884c\u661f\u53f7\u7684\u6570\u91cf\u3002\u901a\u8fc7\u66f4\u6539\u5faa\u73af\u6761\u4ef6\u4e0e\u6253\u5370\u5185\u5bb9\uff0c\u53ef\u7ed8\u5236\u4e0d\u540c\u7684\u661f\u53f7\u56fe\u5f62\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u57fa\u7840\u661f\u53f7\u56fe\u5f62<\/h3>\n<\/p>\n<p><h4>\u6b63\u65b9\u5f62\u56fe\u5f62<\/h4>\n<\/p>\n<p><p>\u8981\u6253\u5370\u4e00\u4e2a\u6b63\u65b9\u5f62\u661f\u53f7\u56fe\u5f62\uff0c\u4f60\u9700\u8981\u8bbe\u7f6e\u4e24\u4e2a\u5d4c\u5957\u7684\u5faa\u73af\uff0c\u4e00\u4e2a\u63a7\u5236\u884c\u6570\uff0c\u53e6\u4e00\u4e2a\u63a7\u5236\u5217\u6570\u3002\u786e\u4fdd\u884c\u548c\u5217\u7684\u6570\u91cf\u76f8\u7b49\uff0c\u8fd9\u6837\u661f\u53f7\u6253\u5370\u51fa\u6765\u5c31\u662f\u6b63\u65b9\u5f62\u5f62\u72b6\u7684\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-c\">int n = 5; \/\/ \u6b63\u65b9\u5f62\u7684\u8fb9\u957f<\/p>\n<p>for(int i = 0; i &lt; n; i++) {<\/p>\n<p>    for(int j = 0; j &lt; n; j++) {<\/p>\n<p>        printf(&quot;* &quot;);<\/p>\n<p>    }<\/p>\n<p>    printf(&quot;\\n&quot;);<\/p>\n<p>}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6bcf\u4e00\u884c\u6253\u53705\u4e2a\u661f\u53f7\uff0c\u5171\u6253\u53705\u884c\u3002<\/p>\n<\/p>\n<p><h4>\u4e09\u89d2\u5f62\u56fe\u5f62<\/h4>\n<\/p>\n<p><p>\u82e5\u8981\u6253\u5370\u4e00\u4e2a\u53f3\u89d2\u4e09\u89d2\u5f62\uff0c\u53ef\u4ee5\u8ba9\u5185\u5c42\u5faa\u73af\u4f9d\u8d56\u4e8e\u5916\u5c42\u5faa\u73af\u7684\u8ba1\u6570\u5668\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-c\">int n = 5; \/\/ \u4e09\u89d2\u5f62\u7684\u9ad8\u5ea6<\/p>\n<p>for(int i = 1; i &lt;= n; i++) {<\/p>\n<p>    for(int j = 1; j &lt;= i; j++) {<\/p>\n<p>        printf(&quot;* &quot;);<\/p>\n<p>    }<\/p>\n<p>    printf(&quot;\\n&quot;);<\/p>\n<p>}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6bcf\u589e\u52a0\u4e00\u884c\uff0c\u661f\u53f7\u7684\u6570\u91cf\u4e5f\u589e\u52a0\u4e00\u4e2a\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u590d\u6742\u661f\u53f7\u56fe\u5f62<\/h3>\n<\/p>\n<p><h4>\u5012\u4e09\u89d2\u5f62\u56fe\u5f62<\/h4>\n<\/p>\n<p><p>\u6253\u5370\u5012\u4e09\u89d2\u5f62\u9700\u8981\u5916\u5c42\u5faa\u73af\u9012\u51cf\uff0c\u5185\u5c42\u5faa\u73af\u5bf9\u5e94\u8c03\u6574\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-c\">int n = 5; \/\/ \u4e09\u89d2\u5f62\u7684\u9ad8\u5ea6<\/p>\n<p>for(int i = n; i &gt; 0; i--) {<\/p>\n<p>    for(int j = 1; j &lt;= i; j++) {<\/p>\n<p>        printf(&quot;* &quot;);<\/p>\n<p>    }<\/p>\n<p>    printf(&quot;\\n&quot;);<\/p>\n<p>}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u4ece5\u4e2a\u661f\u53f7\u5f00\u59cb\u6253\u5370\uff0c\u5e76\u9010\u884c\u51cf\u5c11\u4e00\u4e2a\u661f\u53f7\u3002<\/p>\n<\/p>\n<p><h4>\u6b63\u83f1\u5f62\u56fe\u5f62<\/h4>\n<\/p>\n<p><p>\u6b63\u83f1\u5f62\u56fe\u5f62\u66f4\u52a0\u590d\u6742\uff0c\u56e0\u4e3a\u5b83\u5305\u62ec\u4e00\u4e2a\u4e0a\u534a\u90e8\u5206\u7684\u7b49\u8170\u4e09\u89d2\u5f62\u548c\u4e00\u4e2a\u4e0b\u534a\u90e8\u5206\u7684\u5012\u7b49\u8170\u4e09\u89d2\u5f62\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-c\">int n = 5; \/\/ \u83f1\u5f62\u5bf9\u89d2\u7ebf\u7684\u4e00\u534a<\/p>\n<p>\/\/ \u6253\u5370\u4e0a\u534a\u90e8\u5206<\/p>\n<p>for(int i = 1; i &lt;= n; i++) {<\/p>\n<p>    for(int j = i; j &lt; n; j++) {<\/p>\n<p>        printf(&quot;  &quot;); \/\/ \u6253\u5370\u7a7a\u683c<\/p>\n<p>    }<\/p>\n<p>    for(int j = 1; j &lt;= (2*i - 1); j++) {<\/p>\n<p>        printf(&quot;* &quot;);<\/p>\n<p>    }<\/p>\n<p>    printf(&quot;\\n&quot;);<\/p>\n<p>}<\/p>\n<p>\/\/ \u6253\u5370\u4e0b\u534a\u90e8\u5206<\/p>\n<p>for(int i = 1; i &lt;= n - 1; i++) {<\/p>\n<p>    for(int j = 1; j &lt;= i; j++) {<\/p>\n<p>        printf(&quot;  &quot;);<\/p>\n<p>    }<\/p>\n<p>    for(int j = (2 * (n - i) - 1); j &gt;= 1; j--) {<\/p>\n<p>        printf(&quot;* &quot;);<\/p>\n<p>    }<\/p>\n<p>    printf(&quot;\\n&quot;);<\/p>\n<p>}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e09\u3001\u5faa\u73af\u548c\u63a7\u5236\u7ed3\u6784<\/h3>\n<\/p>\n<p><p>\u8981\u7ed8\u5236\u590d\u6742\u7684\u661f\u53f7\u56fe\u5f62\uff0c\u901a\u5e38\u9700\u8981\u6df1\u5165\u7406\u89e3\u548c\u4f7f\u7528C\u8bed\u8a00\u7684\u5faa\u73af\uff08<code>for<\/code>\u3001<code>while<\/code>\u3001<code>do-while<\/code>\uff09\u548c\u63a7\u5236\u7ed3\u6784\uff08<code>if<\/code>\u3001<code>else<\/code>\u3001<code>switch<\/code>\uff09\u3002\u901a\u8fc7\u7ec4\u5408\u8fd9\u4e9b\u7ed3\u6784\uff0c\u51e0\u4e4e\u53ef\u4ee5\u6253\u5370\u51fa\u4efb\u610f\u5f62\u72b6\u7684\u56fe\u5f62\u3002<\/p>\n<\/p>\n<p><h4>\u4f7f\u7528<code>while<\/code>\u5faa\u73af<\/h4>\n<\/p>\n<p><p><code>while<\/code>\u5faa\u73af\u662f\u53e6\u4e00\u79cd\u53ef\u4ee5\u7528\u6765\u6253\u5370\u661f\u53f7\u56fe\u5f62\u7684\u5faa\u73af\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-c\">int n = 5;<\/p>\n<p>int i = 0, j;<\/p>\n<p>while(i &lt; n) {<\/p>\n<p>    j = 0;<\/p>\n<p>    while(j &lt;= i) {<\/p>\n<p>        printf(&quot;* &quot;);<\/p>\n<p>        j++;<\/p>\n<p>    }<\/p>\n<p>    printf(&quot;\\n&quot;);<\/p>\n<p>    i++;<\/p>\n<p>}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u6bb5\u4ee3\u7801\u7528<code>while<\/code>\u5faa\u73af\u66ff\u4ee3\u4e86<code>for<\/code>\u5faa\u73af\uff0c\u5b8c\u6210\u76f8\u540c\u529f\u80fd\u3002<\/p>\n<\/p>\n<p><h4>\u4f7f\u7528\u63a7\u5236\u8bed\u53e5<\/h4>\n<\/p>\n<p><p>\u63a7\u5236\u8bed\u53e5\u5982<code>if-else<\/code>\u53ef\u4ee5\u7528\u6765\u5728\u6253\u5370\u56fe\u5f62\u65f6\u52a0\u5165\u66f4\u591a\u7684\u590d\u6742\u903b\u8f91\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-c\">int n = 5;<\/p>\n<p>for(int i = 0; i &lt; n; i++) {<\/p>\n<p>    for(int j = 0; j &lt; n; j++) {<\/p>\n<p>        if(i == j || i + j == n - 1) { \/\/ \u6253\u5370\u5bf9\u89d2\u7ebf<\/p>\n<p>            printf(&quot;* &quot;);<\/p>\n<p>        } else {<\/p>\n<p>            printf(&quot;  &quot;);<\/p>\n<p>        }<\/p>\n<p>    }<\/p>\n<p>    printf(&quot;\\n&quot;);<\/p>\n<p>}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u6bb5\u4ee3\u7801\u6253\u5370\u51fa\u5bf9\u89d2\u7ebf\u661f\u53f7\u56fe\u5f62\u3002\u901a\u8fc7\u52a0\u5165\u6761\u4ef6\u5224\u65ad\uff0c\u6211\u4eec\u53ef\u4ee5\u51b3\u5b9a\u662f\u5426\u6253\u5370\u661f\u53f7\u8fd8\u662f\u7a7a\u683c\u3002<\/p>\n<\/p>\n<p><h3>\u56db\u3001\u4ee3\u7801\u4f18\u5316\u4e0e\u5b9e\u8df5<\/h3>\n<\/p>\n<p><p>\u7f16\u5199\u5faa\u73af\u6253\u5370\u661f\u53f7\u56fe\u5f62\u7684\u8fc7\u7a0b\u4e2d\uff0c<strong>\u4ee3\u7801\u4f18\u5316\u662f\u4e00\u4e2a\u91cd\u8981\u7684\u65b9\u9762<\/strong>\u3002\u4f18\u5316\u53ef\u4ee5\u5305\u62ec\u51cf\u5c11\u4ee3\u7801\u5197\u4f59\u3001\u4f7f\u7528\u51fd\u6570\u6765\u5c01\u88c5\u91cd\u590d\u903b\u8f91\u3001\u589e\u5f3a\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u548c\u53ef\u7ef4\u62a4\u6027\u3002<\/p>\n<\/p>\n<p><h4>\u4f7f\u7528\u51fd\u6570\u5c01\u88c5<\/h4>\n<\/p>\n<p><p>\u53ef\u4ee5\u5c06\u7ed8\u5236\u7279\u5b9a\u56fe\u5f62\u7684\u4ee3\u7801\u5c01\u88c5\u5230\u51fd\u6570\u4e2d\uff0c\u4f7f\u4e3b\u51fd\u6570\u66f4\u52a0\u6e05\u6670\u4e14\u6613\u4e8e\u7ba1\u7406\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-c\">void print_square(int n) {<\/p>\n<p>    for(int i = 0; i &lt; n; i++) {<\/p>\n<p>        for(int j = 0; j &lt; n; j++) {<\/p>\n<p>            printf(&quot;* &quot;);<\/p>\n<p>        }<\/p>\n<p>        printf(&quot;\\n&quot;);<\/p>\n<p>    }<\/p>\n<p>}<\/p>\n<p>int main() {<\/p>\n<p>    int size = 5;<\/p>\n<p>    print_square(size);<\/p>\n<p>    return 0;<\/p>\n<p>}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5c06\u6253\u5370\u6b63\u65b9\u5f62\u661f\u53f7\u56fe\u5f62\u7684\u903b\u8f91\u5c01\u88c5\u5230\u4e86<code>print_square<\/code>\u51fd\u6570\u4e2d\u3002<\/p>\n<\/p>\n<p><h4>\u4ee3\u7801\u98ce\u683c\u548c\u547d\u540d\u7ea6\u5b9a<\/h4>\n<\/p>\n<p><p>\u826f\u597d\u7684\u4ee3\u7801\u98ce\u683c\u548c\u547d\u540d\u7ea6\u5b9a\u4f1a\u5927\u5927\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u3002\u6bd4\u5982\uff0c\u4f7f\u7528\u6709\u610f\u4e49\u7684\u53d8\u91cf\u540d\u3001\u4fdd\u6301\u4e00\u81f4\u7684\u7f29\u8fdb\u548c\u7a7a\u683c\u3001\u907f\u514d\u8fc7\u957f\u7684\u51fd\u6570\u7b49\uff0c\u90fd\u662f\u63d0\u5347\u4ee3\u7801\u8d28\u91cf\u7684\u6709\u6548\u505a\u6cd5\u3002<\/p>\n<\/p>\n<p><p>\u968f\u7740\u7f16\u7a0b\u56fe\u5f62\u7684\u590d\u6742\u6027\u589e\u52a0\uff0c\u5173\u6ce8\u4ee3\u7801\u7684\u4f18\u5316\u4e0e\u5b9e\u8df5\u53d8\u5f97\u5c24\u4e3a\u91cd\u8981\u3002\u4f7f\u7528C\u8bed\u8a00\u8fdb\u884c\u661f\u53f7\u56fe\u5f62\u6253\u5370\u662f\u4e00\u4e2a\u5f88\u597d\u7684\u7ec3\u4e60\uff0c\u80fd\u591f\u8ba9\u7f16\u7a0b\u8005\u719f\u6089\u5faa\u73af\u7ed3\u6784\u3001\u7406\u89e3\u7b97\u6cd5\u903b\u8f91\uff0c\u5e76\u63d0\u5347\u89e3\u51b3\u95ee\u9898\u7684\u80fd\u529b\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p><strong>1. \u5982\u4f55\u5728C\u8bed\u8a00\u4e2d\u7f16\u5199\u4e00\u4e2a\u6253\u5370\u661f\u53f7\u56fe\u5f62\u7684\u5faa\u73af\u4ee3\u7801\uff1f<\/strong><\/p>\n<p>\u60a8\u53ef\u4ee5\u4f7f\u7528\u5d4c\u5957\u5faa\u73af\u6765\u6253\u5370\u661f\u53f7\u56fe\u5f62\u3002\u5728\u5916\u90e8\u5faa\u73af\u4e2d\uff0c\u63a7\u5236\u56fe\u5f62\u7684\u884c\u6570\uff0c\u5e76\u5728\u5185\u90e8\u5faa\u73af\u4e2d\u6253\u5370\u661f\u53f7\u7684\u6570\u91cf\u3002\u4f8b\u5982\uff0c\u4ee5\u4e0b\u662f\u4e00\u4e2a\u6253\u5370\u4e09\u89d2\u5f62\u7684\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<pre><code class=\"language-c\">#include &lt;stdio.h&gt;\n\nint main() {\n   int rows, i, j;\n\n   printf(&quot;\u8bf7\u8f93\u5165\u884c\u6570: &quot;);\n   scanf(&quot;%d&quot;, &amp;rows);\n\n   for (i = 1; i &lt;= rows; i++) {\n      for (j = 1; j &lt;= i; j++) {\n         printf(&quot;*&quot;);\n      }\n      printf(&quot;\\n&quot;);\n   }\n\n   return 0;\n}\n<\/code><\/pre>\n<p><strong>2. \u5982\u4f55\u4f7f\u7528\u5faa\u73af\u5728C\u8bed\u8a00\u4e2d\u6253\u5370\u5012\u4e09\u89d2\u661f\u53f7\u56fe\u5f62\uff1f<\/strong><\/p>\n<p>\u8981\u6253\u5370\u5012\u4e09\u89d2\u5f62\uff0c\u60a8\u53ef\u4ee5\u6539\u53d8\u5185\u90e8\u5faa\u73af\u7684\u903b\u8f91\u3002\u5728\u5185\u90e8\u5faa\u73af\u4e2d\uff0c\u4ece\u603b\u884c\u6570\u5f00\u59cb\u9012\u51cf\uff0c\u7136\u540e\u6253\u5370\u76f8\u5e94\u6570\u91cf\u7684\u661f\u53f7\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u6253\u5370\u5012\u4e09\u89d2\u5f62\u7684\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<pre><code class=\"language-c\">#include &lt;stdio.h&gt;\n\nint main() {\n   int rows, i, j;\n\n   printf(&quot;\u8bf7\u8f93\u5165\u884c\u6570: &quot;);\n   scanf(&quot;%d&quot;, &amp;rows);\n\n   for (i = rows; i &gt;= 1; i--) {\n      for (j = 1; j &lt;= i; j++) {\n         printf(&quot;*&quot;);\n      }\n      printf(&quot;\\n&quot;);\n   }\n\n   return 0;\n}\n<\/code><\/pre>\n<p><strong>3. \u5982\u4f55\u5728C\u8bed\u8a00\u4e2d\u4f7f\u7528\u5faa\u73af\u6253\u5370\u83f1\u5f62\u661f\u53f7\u56fe\u5f62\uff1f<\/strong><\/p>\n<p>\u8981\u6253\u5370\u83f1\u5f62\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4e24\u4e2a\u5d4c\u5957\u5faa\u73af\uff0c\u4e00\u4e2a\u7528\u4e8e\u4e0a\u534a\u90e8\u5206\uff0c\u4e00\u4e2a\u7528\u4e8e\u4e0b\u534a\u90e8\u5206\u3002\u5728\u5185\u90e8\u5faa\u73af\u4e2d\uff0c\u60a8\u53ef\u4ee5\u6839\u636e\u5f53\u524d\u884c\u6570\u548c\u603b\u884c\u6570\uff0c\u6253\u5370\u9002\u5f53\u7684\u661f\u53f7\u6570\u91cf\u548c\u7a7a\u683c\u6570\u91cf\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u6253\u5370\u83f1\u5f62\u7684\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<pre><code class=\"language-c\">#include &lt;stdio.h&gt;\n\nint main() {\n   int rows, i, j, space;\n\n   printf(&quot;\u8bf7\u8f93\u5165\u884c\u6570: &quot;);\n   scanf(&quot;%d&quot;, &amp;rows);\n\n   \/\/ \u6253\u5370\u4e0a\u534a\u90e8\u5206\n   for (i = 1; i &lt;= rows; i++) {\n      for (space = 1; space &lt;= rows - i; space++) {\n         printf(&quot; &quot;);\n      }\n      for (j = 1; j &lt;= 2 * i - 1; j++) {\n         printf(&quot;*&quot;);\n      }\n      printf(&quot;\\n&quot;);\n   }\n\n   \/\/ \u6253\u5370\u4e0b\u534a\u90e8\u5206\n   for (i = rows - 1; i &gt;= 1; i--) {\n      for (space = 1; space &lt;= rows - i; space++) {\n         printf(&quot; &quot;);\n      }\n      for (j = 1; j &lt;= 2 * i - 1; j++) {\n         printf(&quot;*&quot;);\n      }\n      printf(&quot;\\n&quot;);\n   }\n\n   return 0;\n}\n<\/code><\/pre>\n<p>\u4ee5\u4e0a\u662f\u51e0\u4e2a\u5728C\u8bed\u8a00\u4e2d\u5faa\u73af\u6253\u5370\u661f\u53f7\u56fe\u5f62\u7684\u793a\u4f8b\u4ee3\u7801\uff0c\u60a8\u53ef\u4ee5\u6839\u636e\u9700\u8981\u8fdb\u884c\u4fee\u6539\u548c\u8c03\u6574\u3002\u5e0c\u671b\u5bf9\u60a8\u6709\u5e2e\u52a9\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728C\u8bed\u8a00\u7f16\u7a0b\u4e2d\uff0c\u8981\u5faa\u73af\u6253\u5370\u661f\u53f7\u56fe\u5f62\uff0c\u53ef\u901a\u8fc7\u4f7f\u7528\u5d4c\u5957\u7684for\u5faa\u73af\u6765\u5b9e\u73b0\u3001\u9010\u884c\u6253\u5370\u661f\u53f7\u3001\u63a7\u5236\u884c\u5217\u7684\u661f\u53f7\u6570\u91cf\u4e0e\u6392\u5217\u3001 [&hellip;]","protected":false},"author":3,"featured_media":311725,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/311692"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=311692"}],"version-history":[{"count":0,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/311692\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/311725"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=311692"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=311692"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=311692"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}