{"id":119050,"date":"2026-10-28T20:24:57","date_gmt":"2026-10-28T12:24:57","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/119050.html"},"modified":"2026-10-28T20:24:57","modified_gmt":"2026-10-28T12:24:57","slug":"c%e8%af%ad%e8%a8%80%ef%bc%9a%e6%95%b0%e7%bb%84","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/119050.html","title":{"rendered":"C\u8bed\u8a00\uff1a\u6570\u7ec4"},"content":{"rendered":"<h2>1. \u6570\u7ec4\u7684\u57fa\u672c\u7528\u6cd5<\/h2>\n<h3>1.1 \u6982\u5ff5<\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#333333\">\u6570\u7ec4(array)\u662f\u6709\u5e8f\u7684\u5143\u7d20\u5e8f\u5217<\/span><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#333333\">\u82e5\u5c06\u6709\u9650\u4e2a\u7c7b\u578b\u76f8\u540c\u7684\u53d8\u91cf\u7684\u96c6\u5408\u547d\u540d&#xff0c;\u90a3\u4e48\u8fd9\u4e2a\u540d\u79f0\u4e3a\u6570\u7ec4\u540d\u3002<\/span><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#333333\">\u91cd\u70b9\u5fc5\u987b\u7c7b\u578b\u76f8\u540c\u548c\u8fde\u7eed\u7684\u53d8\u91cf\u7684\u96c6\u5408<\/span><\/p>\n<h3 style=\"margin-left:0px;margin-right:0px;text-align:justify\"><span style=\"color:#333333\">1.2 \u683c\u5f0f<\/span><\/h3>\n<p><span style=\"color:#333333\">\u5b58\u50a8\u7c7b\u578b \u6570\u636e\u7c7b\u578b \u6570\u7ec4\u540d[\u5143\u7d20\u4e2a\u6570];<\/span><br \/>\n\u4f8b\u5982&#xff1a;(auto) int a[5]; \/\/ \u8fd9\u4e2aauto\u7684\u5176\u4e2d\u4e00\u79cd\u5b58\u50a8\u7c7b\u578b&#xff0c;\u901a\u5e38\u7701\u7565\u4e0d\u5199&#xff0c;\u540e\u9762\u4f1a\u5b66\u5230<\/p>\n<p>\u6570\u7ec4\u540d&#xff1a;<span style=\"color:#333333\">\u4ee3\u8868\u6570\u7ec4\u7684\u9996\u5730\u5740(\u5373\u7b2c\u4e00\u4e2a\u5143\u7d20\u7684\u5730\u5740)&#xff0c;a\u662f\u5730\u5740\u5e38\u91cf&#xff0c;\u4e0d\u80fd\u4e3a\u5de6\u503c&#xff0c;\u4e0d\u80fd\u88ab\u8d4b\u503c\u3002<\/span><\/p>\n<p>\u6570\u7ec4\u7684\u5b9a\u4e49\u65b9\u6cd5&#xff1a;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 1. \u6570\u7ec4\u540d\u5b9a\u4e49\u89c4\u5219\u8ddf\u53d8\u91cf\u540d\u76f8\u540c&#xff0c;\u9075\u5faa\u6807\u8bc6\u7b26\u5b9a\u4e49\u89c4\u5219<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 2. \u6570\u7ec4\u540d\u540e\u4f7f\u7528\u65b9\u62ec\u53f7\u62ec\u8d77\u6765\u7684\u5e38\u91cf\u8868\u8fbe\u5f0f\u8868\u793a\u5143\u7d20\u4e2a\u6570<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 3. \u5e38\u91cf\u8868\u8fbe\u5f0f\u4e2d\u53ef\u4ee5\u5305\u542b\u5e38\u91cf\u548c\u5b8f\u5b9a\u4e49&#xff0c;\u4e0d\u80fd\u5305\u542b\u53d8\u91cf<\/p>\n<h3>1.3 \u8bbf\u95ee\u5143\u7d20<\/h3>\n<p>\u6570\u7ec4\u540d[\u4e0b\u6807];\u00a0 \u00a0 \/\/ \u8fd9\u91cc\u9700\u8981\u6ce8\u610f\u7684\u662f\u4e0b\u6807\u4ece0\u5f00\u59cb<br \/>\n\u4f8b\u5982&#xff1a;\u8bbf\u95ee\u7b2c\u4e00\u4e2a\u5143\u7d20\u5c31\u662f&#xff1a;a[0]<\/p>\n<p>\u6ce8&#xff1a;int a[5]; int b &#061; a[5];<br \/>\n\/\/\u8fd9\u91cc\u7684a[5]\u5c31\u5c5e\u4e8e\u6570\u7ec4\u8d8a\u754c\u9519\u8bef&#xff0c;\u56e0\u4e3a\u6570\u7ec4\u662f\u4ece0\u5f00\u59cb\u7684&#xff0c;\u6570\u7ec4\u4e0b\u6807\u53ea\u6709{0&#xff0c;1&#xff0c;2&#xff0c;3&#xff0c;4}<\/p>\n<p>\u6570\u7ec4\u7684\u7279\u70b9&#xff1a;\u6570\u636e\u7c7b\u578b\u76f8\u540c\u00a0 \u00a0 \u5185\u5b58\u8fde\u7eed<\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#333333\">\u603b\u7ed3\u6ce8\u610f&#xff1a;<\/span><br \/>\n<span style=\"color:#333333\">\u00a0 \u00a0 \u00a0 \u00a0 1. \u6570\u7ec4\u7684\u6570\u636e\u7c7b\u578b\u5c31\u662f\u5143\u7d20\u7684\u6570\u636e\u7c7b\u578b<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a02.\u00a0\u6570\u7ec4\u540d\u8981\u7b26\u5408\u6807\u8bc6\u7b26\u547d\u540d\u89c4\u5219<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 3. \u5728\u540c\u4e00\u4e2a\u51fd\u6570\u4e2d&#xff0c;\u6570\u7ec4\u540d\u4e0d\u8981\u4e0e\u53d8\u91cf\u540d\u76f8\u540c<\/span><br \/>\n<span style=\"color:#333333\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0int a;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 int a[5]; \/\/\u9519\u8bef<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 4. \u4e0b\u6807\u4ece0\u5f00\u59cb&#xff0c;\u5230n-1\u7ed3\u675f<\/span><\/p>\n<h2>2. \u4e00\u7ef4\u6570\u7ec4<\/h2>\n<h3>2.1 \u4e00\u7ef4\u6570\u7ec4\u6982\u5ff5<\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#333333\">\u53ea\u6709\u4e00\u4e2a\u4e0b\u6807\u7684\u6570\u7ec4<\/span><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#333333\">\u683c\u5f0f&#xff1a; \u5b58\u50a8\u7c7b\u578b \u6570\u636e\u7c7b\u578b \u6570\u7ec4\u540d[\u5143\u7d20\u4e2a\u6570];<\/span><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#333333\">\u8bbf\u95ee\u5143\u7d20: \u6570\u7ec4\u540d[\u4e0b\u6807], \u4e0b\u6807\u4ece0\u5f00\u59cb<\/span><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#ff0000\">\u6570\u7ec4\u540d: \u9996\u5730\u5740&#xff0c;<\/span><span style=\"color:#333333\">\u4e5f\u5c31\u662f\u7b2c\u4e00\u4e2a\u5143\u7d20\u7684\u5730\u5740(\u7b49\u4ef7\u4e8e&amp;a[0])<\/span><\/p>\n<h3 style=\"margin-left:0px;margin-right:0px;text-align:justify\"><span style=\"color:#333333\">2.2 \u521d\u59cb\u5316<\/span><\/h3>\n<p><span style=\"color:#333333\">1. \u5b9a\u4e49\u65f6\u5168\u90e8\u521d\u59cb\u5316<\/span><\/p>\n<p>int a[5] &#061; {1, 2, 3, 4, 5};<\/p>\n<p>2. \u5b9a\u4e49\u65f6\u90e8\u5206\u521d\u59cb\u5316&#xff0c;\u672a\u521d\u59cb\u5316\u7684\u5143\u7d20\u503c\u4e3a0<\/p>\n<p>int a[5] &#061; {1, 2}; \/\/ \u53ea\u521d\u59cb\u5316\u524d\u4e24\u4e2a\u5143\u7d20&#xff0c;\u540e\u9762\u7684\u672a\u521d\u59cb\u5316\u5143\u7d20\u4e3a0<\/p>\n<p>3. \u672a\u521d\u59cb\u5316&#xff1a;<span style=\"color:#333333\">\u53ea\u5b9a\u4e49\u672a\u8d4b\u503c&#xff0c;\u9700\u8981\u5355\u4e2a\u5143\u7d20\u8d4b\u503c\u3002(\u4e0d\u7136\u5c40\u90e8\u53d8\u91cf\u662f\u968f\u673a\u503c)<\/span><\/p>\n<p>int a[5];<br \/>\na[0] &#061; 1;<br \/>\na[1] &#061; 2;<br \/>\na[2] &#061; 3;<br \/>\na[3] &#061; 4;<br \/>\na[4] &#061; 5;<\/p>\n<p>\u6ce8\u610f\u5b9a\u4e49\u65f6\u4e0d\u80fd\u6570\u7ec4\u8d8a\u754c&#xff01;&#xff01;&#xff01;<\/p>\n<p>int a[3]&#061;{1,2,3,4}; \/\/\u9519\u8bef&#xff0c;\u6570\u7ec4\u8d8a\u754c!!!<\/p>\n<h3>2.3 \u5b9a\u4e49\u7a7a\u6570\u7ec4<\/h3>\n<p>int a[5]&#061;{0,0,0,0,0};<br \/>\nint a[5]&#061;{0};<br \/>\nint a[5]&#061;{};<\/p>\n<h3>2.4 \u6570\u7ec4\u5f15\u7528<\/h3>\n<li style=\"text-align:justify\"><span style=\"color:#333333\">\u5148\u5b9a\u4e49\u540e\u5f15\u7528<\/span><\/li>\n<li style=\"text-align:justify\"><span style=\"color:#333333\">\u6bcf\u6b21\u53ea\u80fd\u5f15\u7528\u4e00\u4e2a\u6570\u7ec4\u5143\u7d20a[i]&#xff0c;\u5982\u679c\u60f3\u5f15\u7528\u6240\u6709\u7684\u5143\u7d20\u5faa\u73af\u904d\u5386&#xff08;\u6328\u4e2a\u8bbf\u95ee\u6bcf\u4e2a\u6570\u7ec4\u5143\u7d20&#xff09;\u3002<\/span><\/li>\n<li style=\"text-align:justify\"><span style=\"color:#333333\">\u5f15\u7528\u65f6\u4e0d\u8981\u6570\u7ec4\u8d8a\u754c&#xff0c;\u867d\u7136\u6709\u65f6\u5019\u7f16\u8bd1\u5668\u4e0d\u4f1a\u62a5\u9519\u3002<\/span><\/li>\n<li style=\"text-align:justify\"><span style=\"color:#333333\">\u6253\u5370\u6570\u7ec4\u5143\u7d20\u7684\u5730\u5740\u7528%p\u683c\u5f0f\u3002<\/span><\/li>\n<p>\u4f8b\u5982&#xff1a;<br \/>\n#include &lt;stdio.h&gt;<\/p>\n<p>int main(int argc[], char const *argv[])<br \/>\n{<br \/>\n    int a[5] &#061; {1, 2, 3, 4, 5};<br \/>\n    for(int i &#061; 0; i &lt; 5; i&#043;&#043;)<br \/>\n        printf(&#034;%d\\\\n&#034;,a[i]);<br \/>\n    printf(&#034;%p %p\\\\n&#034;, a, &amp;a[0]);<br \/>\n    \/\/ \u8fd9\u91cc\u7684%p\u662f\u4e3a\u4e86\u9a8c\u8bc1\u770b\u4e00\u4e0b\u6570\u7ec4\u540d&#061;&#061;\u9996\u5143\u7d20\u5730\u5740<br \/>\n    return 0;<br \/>\n}<\/p>\n<h3>2.5 \u6570\u7ec4\u5927\u5c0f<\/h3>\n<p>\u4f8b\u5982&#xff1a;<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 int a[5];\u00a0 \u00a0 \/\/20<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 double b[2];\u00a0 \u00a0 \/\/16<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 char c[32];\u00a0 \u00a0 \/\/32<\/p>\n<p>\u8ba1\u7b97\u65b9\u5f0f&#xff1a;<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 1. \u6570\u7ec4\u5143\u7d20\u4e2a\u6570 * \u6570\u636e\u7c7b\u578b\u5927\u5c0f<br \/>\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/\u00a0 \u6570\u7ec4\u5143\u7d20\u4e2a\u6570 &#061; sizeof(\u6570\u7ec4\u540d) \/ sizeof(\u6570\u636e\u7c7b\u578b)<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 2. sizeof(\u6570\u7ec4\u540d)<\/p>\n<p>\u53ef\u4ee5\u7528\u4e0b\u9762\u7684\u7a0b\u5e8f\u81ea\u5df1\u8fd0\u884c\u8bd5\u4e00\u4e0b&#xff1a;<\/p>\n<p>#include &lt;stdio.h&gt;<br \/>\nint main(int argc, char const *argv[])<br \/>\n{<br \/>\n    int a[5];<br \/>\n    double b[2];<br \/>\n    char c[32];<\/p>\n<p>    printf(&#034;%ld\\\\n&#034;, sizeof(a)); \/\/ 20<br \/>\n    printf(&#034;%ld\\\\n&#034;, sizeof(b)); \/\/ 16<br \/>\n    printf(&#034;%ld\\\\n&#034;, sizeof(c)); \/\/ 32<\/p>\n<p>    int n &#061; sizeof(a) \/ sizeof(int);<br \/>\n    printf(&#034;%d\\\\n&#034;, n); \/\/ 5<\/p>\n<p>    return 0;<br \/>\n}<\/p>\n<p>\u8fd9\u4e2a\u5730\u65b9\u4e5f\u6709\u4e00\u4e2a\u975e\u5e38\u7ecf\u5178\u7684\u9898\u76ee&#xff1a;<\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 \u8ba1\u7b97\u6590\u6ce2\u90a3\u5951\u6570\u5217\u524d15\u9879\u5e76\u9006\u5e8f\u8f93\u51fa\u00a0 \u00a0 \u00a0 \u00a0 \/\/ 1 1 2 3 5 8 13 21&#8230;<\/p>\n<p>#include &lt;stdio.h&gt;<br \/>\nint main(int argc, char const *argv[])<br \/>\n{<br \/>\n    int a[15] &#061; {1, 1};          \/\/ \u8d4b\u503c\u524d\u4e24\u4e2a\u5143\u7d20<\/p>\n<p>    for (int i &#061; 2; i &lt; 15; i&#043;&#043;) \/\/ \u4ece\u7b2c\u4e09\u4e2a\u5143\u7d20\u5230\u6700\u540e\u4e00\u4e2a\u5143\u7d20\u904d\u5386\u8d4b\u503c<br \/>\n        a[i] &#061; a[i &#8211; 1] &#043; a[i &#8211; 2];<\/p>\n<p>    for (int i &#061; 14; i &gt;&#061; 0; i&#8211;) \/\/ \u9006\u5e8f\u6253\u5370<br \/>\n        printf(&#034;%d &#034;, a[i]);<\/p>\n<p>    printf(&#034;\\\\n&#034;);<\/p>\n<p>    return 0;<br \/>\n}<\/p>\n<h3>2.6 \u6e05\u96f6\u51fd\u6570<\/h3>\n<h4>2.6.1 bzero()\u51fd\u6570<\/h4>\n<p>#include &lt;strings.h&gt;<br \/>\nvoid bzero(void *s, size_t n);<br \/>\n\u529f\u80fd:\u5c06\u5185\u5b58\u7a7a\u95f4\u8bbe\u7f6e\u4e3a0<br \/>\n\u53c2\u6570&#xff1a;<br \/>\n  s:\u8981\u6e05\u7a7a\u7684\u7a7a\u95f4\u9996\u5730\u5740<br \/>\n  n:\u5b57\u8282\u5927\u5c0f<br \/>\n\u8fd4\u56de\u503c&#xff1a;\u65e0<\/p>\n<h4>2.6.2 memset()\u51fd\u6570<\/h4>\n<p>#include &lt;string.h&gt;<br \/>\nvoid *memset(void *s, int c, size_t n);<br \/>\n\u529f\u80fd&#xff1a;\u5c06\u6307\u5b9a\u5185\u5b58\u7a7a\u95f4\u5185\u5bb9\u8bbe\u7f6e\u4e3a0<br \/>\n\u53c2\u6570&#xff1a;s:\u6307\u5b9a\u5185\u5b58\u9996\u5730\u5740<br \/>\n    c:\u8981\u8bbe\u7f6e\u7684\u6570&#xff0c;\u4e00\u822c\u4e3a0<br \/>\n    n&#xff1a;\u8981\u8bbe\u7f6e\u7684\u5185\u5b58\u5927\u5c0f<br \/>\n\u8fd4\u56de\u503c&#xff1a;\u6307\u5b9a\u5185\u5b58\u9996\u5730\u5740&#xff08;\u4e00\u822c\u4e0d\u7528&#xff09;<\/p>\n<p>\u8fd9\u4e24\u4e2a\u51fd\u6570\u6682\u65f6\u7528\u4e0d\u7740\u4f46\u662f\u4e5f\u5f88\u91cd\u8981\u5728\u540e\u9762\u5b66\u4e60\u5355\u7247\u673a\u7684\u65f6\u5019<\/p>\n<h3>2.7 \u6570\u7ec4\u7684\u5185\u5b58\u5206\u914d<\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#333333\">int a[<\/span><span style=\"color:#333333\">5<\/span><span style=\"color:#333333\">]<\/span><span style=\"color:#333333\">;<\/span><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#333333\">a\u662f\u6570\u7ec4\u540d&#xff0c;\u662f\u6570\u7ec4\u7684\u9996\u5730\u5740&#xff0c;\u4e5f\u5c31\u662f\u7b2c\u4e00\u4e2a\u5143\u7d20\u7684\u5730\u5740\u5373&amp;a[<\/span><span style=\"color:#333333\">0]<\/span><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#333333\">a&#043;1\u662f\u7b2c\u4e8c\u4e2a\u5143\u7d20\u7684\u5730\u5740&#xff0c;\u5373&amp;a[1]<\/span><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#333333\">\u6ce8\u610f&#xff1a;\u8fd9\u91cc\u7684\u5730\u5740&#043;1\u8868\u793a\u4e0b\u4e00\u4e2a\u5143\u7d20\u7684\u5730\u5740&#xff0c;\u800c\u4e0d\u662f\u6570\u503c\u4e0a&#043;1<\/span><\/p>\n<table border=\"1\" cellpadding=\"1\" cellspacing=\"1\" style=\"width:500px\">\n<tbody>\n<tr>\n<td>int a[5];<\/td>\n<td>\u5730\u5740<\/td>\n<td>\u5730\u5740<\/td>\n<\/tr>\n<tr>\n<td>a[0]<\/td>\n<td>&amp;a[0]<\/td>\n<td>a<\/td>\n<\/tr>\n<tr>\n<td>a[1]<\/td>\n<td>&amp;a[1]<\/td>\n<td>a&#043;1<\/td>\n<\/tr>\n<tr>\n<td>a[2]<\/td>\n<td>&amp;a[2]<\/td>\n<td>a&#043;2<\/td>\n<\/tr>\n<tr>\n<td>a[3]<\/td>\n<td>&amp;a[3]<\/td>\n<td>a&#043;3<\/td>\n<\/tr>\n<tr>\n<td>a[4]<\/td>\n<td>&amp;a[4]<\/td>\n<td>a&#043;4<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u53ef\u4ee5\u7528\u4e0b\u9762\u7684\u4ee3\u7801\u770b\u4e00\u4e0b\u4e24\u8005\u8868\u793a\u7684\u5730\u5740\u662f\u4e00\u6837\u7684<\/p>\n<p>#include &lt;stdio.h&gt;<br \/>\nint main(int argc, char const *argv[])<br \/>\n{<br \/>\n    int a[5];<br \/>\n    for(int i &#061; 0; i &lt; 5; i&#043;&#043;)<br \/>\n        printf(&#034;%p %p\\\\n&#034;, &amp;a[i], a &#043; i);<br \/>\n    return 0;<br \/>\n}<\/p>\n<h2>3. \u5b57\u7b26\u6570\u7ec4<\/h2>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#333333\">\u56e0\u4e3aC\u8bed\u8a00\u6ca1\u6709\u5b57\u7b26\u4e32\u7c7b\u578b&#xff0c;\u6240\u4ee5\u53ef\u4ee5\u7528\u5b57\u7b26\u6570\u7ec4\u7684\u5f62\u5f0f\u8868\u793a\u5b57\u7b26\u4e32\u3002<\/span><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#333333\">\u7c7b\u578b\u4e3a\u5b57\u7b26\u7684\u6570\u7ec4\u5c31\u662f\u5b57\u7b26\u6570\u7ec4&#xff0c;\u4e5f\u5c31\u662f\u8bf4\u6570\u7ec4\u4e2d\u6bcf\u4e2a\u5143\u7d20\u662f\u5b57\u7b26\u7c7b\u578b&#xff0c;\u53ef\u4ee5\u8868\u793a\u5b57\u7b26\u4e32\u3002<\/span><\/p>\n<h3 style=\"margin-left:0px;margin-right:0px;text-align:justify\"><span style=\"color:#333333\">3.1 \u5b9a\u4e49\u65f6\u521d\u59cb\u5316\u8868\u793a\u5f62\u5f0f<\/span><\/h3>\n<p><span style=\"color:#333333\">1. \u5355\u4e2a\u5b57\u7b26&#xff1a;<\/span><\/p>\n<p>char s1[5] &#061; {&#039;h&#039;,&#039;e&#039;,&#039;l&#039;,&#039;l&#039;,&#039;o&#039;}; \/\/sizeof(s1)&#061;5<br \/>\nchar s2[] &#061; {&#039;h&#039;,&#039;e&#039;,&#039;l&#039;,&#039;l&#039;,&#039;o&#039;};  \/\/sizeof(s2)&#061;5<\/p>\n<p>2. \u7528\u5b57\u7b26\u4e32\u8868\u793a&#xff0c;\u7ed3\u5c3e\u4f1a\u81ea\u52a8\u52a0\u4e0a&#039;\\\\0&#039;<\/p>\n<p>char s1[]&#061;{&#034;hello&#034;};  \/\/sizeof(s1)&#061;6 \u56e0\u4e3a\u7ed3\u5c3e\u4f1a\u81ea\u52a8\u6dfb\u52a0&#039;\\\\0&#039;<br \/>\nchar s2[]&#061;&#034;hello&#034;;    \/\/sizeof(s2)&#061;6<br \/>\nchar s3[6]&#061;{&#034;hello&#034;}; \/\/sizeof(s3)&#061;6<br \/>\nchar s4[6]&#061;&#034;hello&#034;;   \/\/sizeof(s4)&#061;6<br \/>\nchar s5[]&#061;{};  \/\/\u9519\u8bef<\/p>\n<h3>3.2 \u8f93\u5165\u8f93\u51fa<\/h3>\n<p>1. \u7528 scanf \/ printf<\/p>\n<p>char s[32] &#061; &#034;hello&#034;;<br \/>\nprintf(&#034;%s\\\\n&#034;, s);  \/\/ \u6253\u5370\u5b57\u7b26\u4e32<br \/>\nscanf(&#034;%s&#034;, s);     \/\/ \u8f93\u5165\u5b57\u7b26\u4e32&#xff0c;\u8f93\u5165\u5b8c\u4f1a\u81ea\u52a8\u6dfb\u52a0&#039;\\\\0&#039;\u4f5c\u4e3a\u5b57\u7b26\u4e32\u7ed3\u5c3e\u7684\u6807\u5fd7&#xff0c;<br \/>\n                    \/\/ \u4f46\u662f\u8be5\u5199\u6cd5\u4e0d\u80fd\u63a5\u53d7\u7a7a\u683c\u7684\u8f93\u5165&#xff08;\u7a7a\u683c\u3001\u56de\u8f66\u3001Tab\u90fd\u4f1a\u5f53\u6210\u8f93\u5165\u6807\u5fd7&#xff09;<br \/>\nprintf(&#034;%s\\\\n&#034;, s);  \/\/ \u6253\u5370\u5230\\\\0\u5c31\u505c\u4e86<br \/>\n\/*\u9a8c\u8bc1*\/<br \/>\nfor (int i &#061; 0; i &lt; 32; i&#043;&#043;)<br \/>\n    printf(&#034;%d: %c\\\\n&#034;, i, s[i]);<\/p>\n<p>\u7531\u4e8escanf(&#034;%s\\\\n&#034;, s);\u4e0d\u80fd\u8f93\u5165\u7a7a\u683c&#xff0c;\u5982\u679c\u6709\u7a7a\u683c&#xff0c;\u7a7a\u683c\u540e\u9762\u7684\u5185\u5bb9\u5c31\u4e0d\u4f1a\u5b58\u5165\u5230\u6570\u7ec4<\/p>\n<p>\u5982\u679c\u9700\u8981\u6709\u7a7a\u683c<br \/>\nscanf(&#034;%[^\\\\n]&#034;,str);<br \/>\n\/\/\u6b63\u5219\u8868\u8fbe\u5f0f&#xff0c;\u53ef\u4ee5\u8f93\u5165\u9664\u4e86\\\\n\u4ee5\u5916\u7684\u5b57\u7b26&#xff0c;\u9047\u5230\\\\n\u7ed3\u675f<\/p>\n<p>2. \u7528for\u5faa\u73af\u904d\u5386\u8f93\u5165\u8f93\u51fa<\/p>\n<p>#include &lt;stdio.h&gt;<\/p>\n<p>int main(int argc, char const *argv[])<br \/>\n{<br \/>\n    char str[6] &#061; &#034;&#034;;<br \/>\n    for (int i &#061; 0; i &lt; 6; i&#043;&#043;)<br \/>\n        scanf(&#034;%c&#034;, &amp;str[i]);<br \/>\n    for (int i &#061; 0; i &lt; 6; i&#043;&#043;)<br \/>\n        printf(&#034;%c&#034;, str[i]);<\/p>\n<p>    return 0;<br \/>\n}<\/p>\n<p>\u4f8b\u9898&#xff1a;\u8f93\u5165\u4e00\u4e2a\u5b57\u7b26\u4e32&#xff0c;\u8ba1\u7b97\u5176\u7a7a\u683c\u4e2a\u6570<\/p>\n<p>#include &lt;stdio.h&gt;<\/p>\n<p>int main(int argc, char const *argv[])<br \/>\n{<br \/>\n    int n &#061; 0;<br \/>\n    char s[32] &#061; &#034;&#034;;<br \/>\n    scanf(&#034;%[^\\\\n]&#034;, s);<br \/>\n    \/\/ for (int i &#061; 0; i &lt; 32; i&#043;&#043;)<br \/>\n    for (int i &#061; 0; s[i] !&#061; &#039;\\\\0&#039;; i&#043;&#043;)<br \/>\n    {<br \/>\n        if (s[i] &#061;&#061; &#039; &#039;)<br \/>\n            n&#043;&#043;;<br \/>\n    }<br \/>\n    printf(&#034;%d\\\\n&#034;, n);<\/p>\n<p>    return 0;<br \/>\n}<\/p>\n<p>\u6613\u9519\u70b9&#xff1a;<\/p>\n<p>char s[10] &#061; {}; \/\/\u5bf9\u7684<br \/>\ns[10] &#061; &#034;hello&#034;; \/\/\u9519\u8bef&#xff0c;\u4e0d\u80fd\u5c06\u5b57\u7b26\u4e32\u8d4b\u503c\u7ed9\u6570\u7ec4\u5143\u7d20<br \/>\n                 \/\/\u505a\u9898\u975e\u5e38\u6613\u9519<br \/>\ns &#061; &#034;hello&#034;;     \/\/\u9519\u8bef&#xff0c;s\u662f\u5730\u5740\u5e38\u91cf&#xff0c;\u4e0d\u80fd\u4e3a\u5de6\u503c<br \/>\nstrcpy(s, &#034;hello&#034;); \/\/\u6b63\u786e&#xff0c;\u8fd9\u662f\u4e00\u4e2a\u51fd\u6570\u53ef\u4ee5\u4e86\u89e3\u4e00\u4e0b<\/p>\n<h3>3.3 \u8ba1\u7b97\u5b57\u7b26\u4e32\u957f\u5ea6<\/h3>\n<h4>3.3.1 \u7528\u5faa\u73af\u7edf\u8ba1<\/h4>\n<p>\u8fd9\u4e2a\u65f6\u5019\u7528while\u662f\u66f4\u52a0\u65b9\u4fbf\u7684<\/p>\n<p>#include &lt;stdio.h&gt;<\/p>\n<p>int main(int argc, char const *argv[])<br \/>\n{<br \/>\n    char str[32] &#061; &#034;hello world&#034;;<br \/>\n    int i &#061; 0;<br \/>\n    while (str[i] !&#061; &#039;\\\\0&#039;)<br \/>\n    {<br \/>\n        i&#043;&#043;;<br \/>\n    }<br \/>\n    printf(&#034;%d\\\\n&#034;, i);<\/p>\n<p>    return 0;<br \/>\n}<\/p>\n<h4>3.3.2 \u7528strlen()<\/h4>\n<p>#include &lt;string.h&gt;<br \/>\nsize_t strlen(const char *s);<br \/>\n\u529f\u80fd&#xff1a;\u8ba1\u7b97\u5b57\u7b26\u4e32\u957f\u5ea6<br \/>\n\u53c2\u6570&#xff1a;\u5b57\u7b26\u4e32\u7684\u9996\u5730\u5740<br \/>\n\u8fd4\u56de\u503c&#xff1a;\u8fd4\u56de\u5b57\u7b26\u4e32\u5b9e\u9645\u957f\u5ea6&#xff0c;\u4e0d\u5305\u62ec\u2018\\\\0\u2019\u5728\u5185\u3002<\/p>\n<h4>3.3.3 sizeof \u548c strlen\u00a0 \u7684\u533a\u522b<\/h4>\n<li style=\"text-align:justify\"><span style=\"color:#333333\">sizeof\u662f\u5173\u952e\u5b57&#xff0c;strlen\u662f\u51fd\u6570\u3002<\/span><\/li>\n<li style=\"text-align:justify\"><span style=\"color:#333333\">sizeof\u662f\u8ba1\u7b97\u6570\u636e\u6240\u5360\u7a7a\u95f4\u5927\u5c0f&#xff0c;strlen\u53ea\u80fd\u8ba1\u7b97\u5b57\u7b26\u4e32\u7684\u5b9e\u9645\u957f\u5ea6\u3002<\/span><\/li>\n<li style=\"text-align:justify\"><span style=\"color:#333333\">\u5b9a\u4e49\u5b57\u7b26\u4e32\u6570\u7ec4\u540c\u65f6\u8d4b\u503c\u4e14\u7701\u7565\u5143\u7d20\u4e2a\u6570\u65f6&#xff0c;sizeof\u8ba1\u7b97\u5b57\u7b26\u4e32\u5305\u542b&#039;\\\\0&#039;,strlen\u8ba1\u7b97\u4e0d\u5305\u542b&#039;\\\\0&#039;&#xff0c;\u8ba1\u7b97\u5b57\u7b26\u4e32\u957f\u5ea6&#xff0c;sizeof\u6bd4strlen\u8ba1\u7b97\u591a1<\/span><\/li>\n<h2 style=\"text-align:justify\">4.\u00a0\u6392\u5e8f&#xff08;\u91cd\u4e2d\u4e4b\u91cd&#xff01;&#xff01;&#xff01;&#xff09;<\/h2>\n<h3>4.1 \u5192\u6ce1\u6392\u5e8f<\/h3>\n<p>\u6392\u5e8f\u8fc7\u7a0b&#xff1a;<\/p>\n<li style=\"text-align:justify\"><span style=\"color:#333333\">\u6bd4\u8f83\u7b2c\u4e00\u4e2a\u548c\u7b2c\u4e8c\u4e2a\u5143\u7d20&#xff0c;\u5982\u679c\u7b2c\u4e00\u4e2a\u5927\u4e8e\u7b2c\u4e8c\u4e2aa[0]&gt;a[1]\u5219\u4ea4\u6362&#xff0c;\u7136\u540e\u6bd4\u8f83\u7b2c\u4e8c\u4e2a\u548c\u7b2c\u4e09\u4e2a\u6570&#xff0c;\u524d\u9762\u7684\u5927\u5c31\u4ea4\u6362&#xff1b;\u4f9d\u6b21\u7c7b\u63a8&#xff0c;\u76f4\u5230\u7b2cn-1\u548c\u7b2cn\u4e2a\u6570\u6bd4\u8f83\u5b8c\u4e3a\u6b62\u3002\u7b2c\u4e00\u8d9f\u5192\u6ce1\u6392\u5e8f\u5b8c\u6210&#xff0c;\u7ed3\u679c\u6700\u5927\u7684\u6570\u88ab\u653e\u5728\u6700\u540e\u4e00\u4e2a\u5143\u7d20\u4f4d\u7f6e\u4e0a\u4e86\u3002<\/span><\/li>\n<li style=\"text-align:justify\"><span style=\"color:#333333\">\u5bf9\u524dn-1\u4e2a\u6570\u8fdb\u884c\u7b2c\u4e8c\u8d9f\u5192\u6ce1\u6392\u5e8f&#xff0c;\u7ed3\u679c\u4f7f\u6b21\u5927\u7684\u6570\u653e\u5728\u7b2cn-1\u4e2a\u5143\u7d20\u4f4d\u7f6e\u4e0a\u4e86\u3002<\/span><\/li>\n<li style=\"text-align:justify\"><span style=\"color:#333333\">\u91cd\u590d\u4e0a\u8ff0\u8fc7\u7a0b&#xff0c;\u5171\u7ecf\u8fc7n-1\u8d9f\u5192\u6ce1\u6392\u5e8f\u540e&#xff0c;\u6392\u5e8f\u7ed3\u675f<\/span><br \/>\n<img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"253\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261028122455-6ae1e99785f9a.gif\" width=\"555\" \/><\/p>\n<p>\u5916\u5c42\u5faa\u73af\u8f6e\u6570i&#061;\u4e2a\u6570-1 &#061; N-1(0\u5230&lt;N-1)<br \/>\n\u5185\u5b58\u5faa\u73af\u6bd4\u8f83\u6b21\u6570j &#061; \u4e2a\u6570-1-\u8f6e\u6570(\u4ece0\u5f00\u59cb) &#061; N-1-i<br \/>\n#include &lt;stdio.h&gt;<br \/>\n#define N 5<\/p>\n<p>int main(int argc, char const *argv[])<br \/>\n{<br \/>\n    int a[N] &#061; {5, 4, 3, 2, 1}, t;<br \/>\n    for (int i &#061; 0; i &lt; N &#8211; 1; i&#043;&#043;) \/\/ \u5916\u5c42\u5faa\u73af\u8f6e\u6570<br \/>\n    {<br \/>\n        for (int j &#061; 0; j &lt; N &#8211; 1 &#8211; i; j&#043;&#043;) \/\/ \u5185\u5c42\u5faa\u73af\u6bd4\u8f83\u6b21\u6570<br \/>\n        {<br \/>\n            if (a[j] &gt; a[j &#043; 1]) \/\/ \u6bd4\u8f83<br \/>\n            {<br \/>\n                \/\/ \u4ea4\u6362<br \/>\n                t &#061; a[j];<br \/>\n                a[j] &#061; a[j &#043; 1];<br \/>\n                a[j &#043; 1] &#061; t;<br \/>\n            }<br \/>\n        }<br \/>\n    }<br \/>\n    for (int i &#061; 0; i &lt; N; i&#043;&#043;)<br \/>\n        printf(&#034;%d &#034;, a[i]);<br \/>\n    printf(&#034;\\\\n&#034;);<\/p>\n<p>    return 0;<br \/>\n}<\/p>\n<h3><\/h3>\n<\/li>\n<h3 style=\"text-align:justify\">4.2 \u9009\u62e9\u6392\u5e8f<\/h3>\n<p>\u6392\u5e8f\u8fc7\u7a0b&#xff1a;<\/p>\n<li style=\"text-align:justify\"><span style=\"color:#333333\">\u9996\u5148\u901a\u8fc7n-1\u6b21\u6bd4\u8f83&#xff0c;\u4ecen\u4e2a\u6570\u4e2d\u627e\u5230\u6700\u5c0f\u7684\u6570&#xff0c;\u5c06\u5b83\u4e0e\u7b2c\u4e00\u4e2a\u6570\u4ea4\u6362&#xff0c;\u7b2c\u4e00\u8d9f\u9009\u62e9\u6392\u5e8f\u7ed3\u679c\u6700\u5c0f\u6570\u88ab\u5b89\u7f6e\u5728\u7b2c\u4e00\u4e2a\u5143\u7d20\u4f4d\u7f6e\u4e0a\u3002<\/span><\/li>\n<li style=\"text-align:justify\"><span style=\"color:#333333\">\u518d\u901a\u8fc7n-2\u6b21\u6bd4\u8f83&#xff0c;\u4ece\u5269\u4f59\u7684n-1\u4e2a\u6570\u4e2d\u627e\u5230\u6b21\u5c0f\u7684\u6570&#xff0c;\u5c06\u5b83\u4e0e\u7b2c\u4e8c\u4e2a\u6570\u4ea4\u6362&#xff0c;\u7b2c\u4e8c\u8d9f\u9009\u62e9\u6392\u5e8f\u5c06\u6b21\u5c0f\u7684\u6570\u5b89\u7f6e\u5728\u7b2c\u4e8c\u4e2a\u5143\u7d20\u4f4d\u7f6e\u4e0a\u3002<\/span><\/li>\n<li style=\"text-align:justify\"><span style=\"color:#333333\">\u91cd\u590d\u4e0a\u8ff0\u8fc7\u7a0b&#xff0c;\u5171\u7ecf\u8fc7n-1\u8d9f\u6392\u5e8f\u540e&#xff0c;\u6392\u5e8f\u7ed3\u675f\u3002<\/span><br \/>\n<img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"257\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261028122456-6ae1e9980381a.gif\" width=\"555\" \/><\/li>\n<p>\u8f6e\u6570&#061;\u4e2a\u6570-1&#061;N-1(\u540c\u5192\u6ce1)<br \/>\n\u6bcf\u8f6e\u6bd4\u8f83\u7684j: \u4ecei&#043;1\u5f00\u59cb\u5230\u6700\u540e\u4e00\u4e2a\u5143\u7d20N-1<br \/>\n#include &lt;stdio.h&gt;<\/p>\n<p>int main(int argc, char const *argv[])<br \/>\n{<br \/>\n    int a[5] &#061; {76, 56, 1, 45, 10};<br \/>\n    int min &#061; 0, t;<br \/>\n    for (int i &#061; 0; i &lt; 4; i&#043;&#043;) \/\/ \u5916\u5c42\u5faa\u73af\u8f6e\u6570(\u540c\u5192\u6ce1)<br \/>\n    {<br \/>\n        min &#061; i;                        \/\/ \u62ff\u7740\u4e0b\u6807\u4e3ai\u7684\u5143\u7d20\u5f00\u59cb\u6bd4\u8f83<br \/>\n        for (int j &#061; i &#043; 1; j &lt; 5; j&#043;&#043;) \/\/ \u4ecei\u7684\u540e\u4e00\u4e2a\u5143\u7d20\u5f00\u59cb\u4e00\u76f4\u6bd4\u8f83\u5230\u6700\u540e\u4e00\u4e2a\u5143\u7d20<br \/>\n        {<br \/>\n            if (a[j] &lt; a[min]) \/\/ \u5982\u679c\u6709\u66f4\u5c0f\u7684\u6570<br \/>\n                min &#061; j;<br \/>\n        } \/\/ \u5faa\u73af\u7ed3\u675f\u540e\u6700\u5c0f\u5143\u7d20\u7684\u4e0b\u6807\u5c31\u88abmin\u4fdd\u5b58\u4e86<\/p>\n<p>        \/\/ \u4ea4\u6362\u6700\u5c0f\u7684\u5143\u7d20\u548c\u524d\u9762\u7684\u5143\u7d20<br \/>\n        if (a[min] !&#061; a[i])<br \/>\n        {<br \/>\n            t &#061; a[min];<br \/>\n            a[min] &#061; a[i];<br \/>\n            a[i] &#061; t;<br \/>\n        }<br \/>\n    }<br \/>\n    for (int i &#061; 0; i &lt; 5; i&#043;&#043;)<br \/>\n        printf(&#034;%d &#034;, a[i]);<br \/>\n    printf(&#034;\\\\n&#034;);<\/p>\n<p>    return 0;<br \/>\n}<\/p>\n<h2>5. \u4e8c\u7ef4\u6570\u7ec4<\/h2>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#333333\">\u4e8c\u7ef4\u6570\u7ec4<\/span><span style=\"color:#333333\">\u4e0b\u6807\u4e3a\u4e24\u4e2a\u7684\u6570\u7ec4&#xff0c;\u4e0b\u6807\u5206\u522b\u662f\u884c\u4e0b\u6807\u548c\u5217\u4e0b\u6807\u3002<\/span><\/p>\n<h3 style=\"margin-left:0px;margin-right:0px;text-align:justify\"><span style=\"color:#333333\">5.1 \u5b9a\u4e49\u683c\u5f0f<\/span><\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#333333\">\u5b58\u50a8\u7c7b\u578b \u6570\u636e\u7c7b\u578b \u6570\u7ec4\u540d[\u884c\u6570][\u5217\u6570];<\/span><\/p>\n<h3 style=\"margin-left:0px;margin-right:0px;text-align:justify\"><span style=\"color:#333333\">5.2 \u8bbf\u95ee\u5143\u7d20<\/span><\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#333333\">\u6570\u7ec4\u540d[\u884c\u4e0b\u6807][\u5217\u4e0b\u6807]; (\u4e0b\u6807\u90fd\u4ece0\u5f00\u59cb)<\/span><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#333333\">a[0][0]; \/\/\u7b2c\u4e00\u884c\u7b2c\u4e00\u5217<\/span><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#333333\">a[n-1][m-1]; \/\/\u7b2cn\u884c\u7b2cm\u5217\u5143\u7d20<\/span><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#333333\">\u6ce8\u610f: <\/span><\/p>\n<li style=\"text-align:justify\"><span style=\"color:#333333\">\u884c\u4e0b\u6807\u548c\u5217\u4e0b\u6807\u90fd\u662f\u4ece0\u5f00\u59cb&#xff0c;\u4e0d\u80fd\u8d8a\u754c!!!<\/span><\/li>\n<li style=\"text-align:justify\"><span style=\"color:#333333\">\u5b9a\u4e49\u540c\u65f6\u521d\u59cb\u5316\u65f6\u884c\u6570\u53ef\u4ee5\u7701\u7565&#xff0c;\u5217\u6570\u4e0d\u80fd\u7701\u7565<\/span><\/li>\n<li style=\"text-align:justify\"><span style=\"color:#333333\">\u6570\u7ec4\u540d\u4ee3\u8868\u6570\u7ec4\u9996\u884c\u5730\u5740<\/span><\/li>\n<h3 style=\"text-align:justify\"><span style=\"color:#333333\">5.3 \u4e8c\u7ef4\u6570\u7ec4\u5927\u5c0f<\/span><\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#333333\">\u5143\u7d20\u4e2a\u6570 &#061; \u884c\u6570 * \u5217\u6570<\/span><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#333333\">\u4e8c\u7ef4\u6570\u7ec4\u5927\u5c0f:<\/span><\/p>\n<li style=\"text-align:justify\"><span style=\"color:#333333\">\u884c\u6570*\u5217\u6570*\u6570\u636e\u7c7b\u578b\u5927\u5c0f<\/span><\/li>\n<li style=\"text-align:justify\"><span style=\"color:#333333\">sizeof(\u6570\u7ec4\u540d)<\/span><\/li>\n<h3 style=\"text-align:justify\">5.4 \u521d\u59cb\u5316\u4e8c\u7ef4\u6570\u7ec4<\/h3>\n<li style=\"text-align:justify\"><span style=\"color:#333333\">\u5b9a\u4e49\u65f6\u5168\u90e8\u521d\u59cb\u5316<\/span><br \/>\n<span style=\"color:#333333\">int a[2][3] &#061; {{1,2,3},{4,5,6}}; \/\/\u6309\u884c\u8d4b\u503c<\/span><br \/>\n<span style=\"color:#333333\">int a[2][3] &#061; {1,2,3,4,5,6}; \/\/\u987a\u5e8f\u8d4b\u503c<\/span><\/li>\n<li style=\"text-align:justify\"><span style=\"color:#333333\">\u5b9a\u4e49\u65f6\u90e8\u5206\u521d\u59cb\u5316&#xff0c;\u672a\u521d\u59cb\u5316\u7684\u5143\u7d20\u503c\u4e3a0<\/span><br \/>\n<span style=\"color:#333333\">int a[2][3] &#061; {{1,2},{4,5}}; \/\/\u6309\u884c\u8d4b\u503c<\/span><br \/>\n<span style=\"color:#333333\">int a[2][3] &#061; {1,2,3,4,}; \/\/\u987a\u5e8f\u8d4b\u503c<\/span><\/li>\n<li style=\"text-align:justify\"><span style=\"color:#333333\">\u5148\u5b9a\u4e49\u540e\u521d\u59cb\u5316&#xff0c;\u672a\u521d\u59cb\u5316&#xff0c;\u9700\u8981\u7ed9\u6bcf\u4e2a\u5143\u7d20\u5355\u72ec\u8d4b\u503c<\/span><\/li>\n<h3 style=\"text-align:justify\"><span style=\"color:#333333\">5.5 \u904d\u5386\u4e8c\u7ef4\u6570\u7ec4<\/span><\/h3>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#333333\">\u5faa\u73af\u5d4c\u5957\u6765\u904d\u5386\u4e8c\u7ef4\u6570\u7ec4&#xff0c;\u5916\u5c42\u5faa\u73af\u884c\u6570&#xff0c;\u5185\u5c42\u5faa\u73af\u5217\u6570\u3002<\/span><\/p>\n<p>#include &lt;stdio.h&gt;<\/p>\n<p>int main(int argc, char const *argv[])<br \/>\n{<br \/>\n    int a[2][3] &#061; {{1, 2}, {4, 5}};<br \/>\n    for (int i &#061; 0; i &lt; 2; i&#043;&#043;)<br \/>\n    {<br \/>\n        for (int j &#061; 0; j &lt; 3; j&#043;&#043;)<br \/>\n            printf(&#034;%d &#034;, a[i][j]);<br \/>\n        printf(&#034;\\\\n&#034;);<br \/>\n    }<br \/>\n    return 0;<br \/>\n}<\/p>\n<h3>5.6 \u5185\u5b58\u5206\u914d<\/h3>\n<table border=\"1\" cellpadding=\"1\" cellspacing=\"1\" style=\"width:500px\">\n<tbody>\n<tr>\n<td colspan=\"4\">int[2][3]\u4e3a\u4f8b<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td>\u884c\u5730\u5740<\/td>\n<td>\u5217\u5730\u5740<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>a[0][0]<\/td>\n<td>&amp;a[0][0]<\/td>\n<td>*a<\/td>\n<td>a[0]<\/td>\n<\/tr>\n<tr>\n<td>a[0][1]<\/td>\n<td>&amp;a[0][1]<\/td>\n<td>*a&#043;1<\/td>\n<td>a[0]&#043;1<\/td>\n<\/tr>\n<tr>\n<td>a[0][2]<\/td>\n<td>&amp;a[0][2]<\/td>\n<td>*a&#043;2<\/td>\n<td>a[0]&#043;2<\/td>\n<\/tr>\n<tr>\n<td>a[1][0]<\/td>\n<td>&amp;a[1][0]<\/td>\n<td>*(a&#043;1)<\/td>\n<td>a[1]<\/td>\n<\/tr>\n<tr>\n<td>a[1][1]<\/td>\n<td>&amp;a[1][1]<\/td>\n<td>*(a&#043;1)&#043;1<\/td>\n<td>a[1]&#043;1<\/td>\n<\/tr>\n<tr>\n<td>a[1][2]<\/td>\n<td>&amp;a[1][2]<\/td>\n<td>*(a&#043;1)&#043;2<\/td>\n<td>a[1]&#043;2<\/td>\n<\/tr>\n<tr>\n<td>a[i][j]<\/td>\n<td>&amp;a[i][j]<\/td>\n<td>*(a&#043;i)&#043;j<\/td>\n<td>a[i]&#043;j<\/td>\n<\/tr>\n<tr>\n<td colspan=\"4\">\u884c\u5730\u5740\u524d\u9762\u52a0*\u4ee3\u8868\u964d\u7ea7\u4e3a\u5217\u5730\u5740&#xff08;\u8be5\u884c\u7b2c\u4e00\u5217\u7684\u5730\u5740&#xff09;<\/td>\n<\/tr>\n<tr>\n<td colspan=\"4\">\u6570\u7ec4\u540d[\u884c\u4e0b\u6807]\u4ee3\u8868\u8fd9\u4e00\u884c\u7b2c\u5217\u7684\u5730\u5740\u00a0<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p style=\"text-align:justify\"><span style=\"color:#333333\">1. \u884c\u5730\u5740<\/span><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#333333\">\u4e8c\u7ef4\u6570\u7ec4\u4e2d&#xff0c;\u6570\u7ec4\u540da\u8868\u793a\u7b2c\u4e00\u884c\u7684\u5730\u5740&#xff0c;\u5176\u6570\u503c\u548c\u7b2c\u4e00\u884c\u7b2c\u4e00\u5217\u7684\u5730\u5740\u5373&amp;a[0][0]\u4e00\u6837&#xff0c;\u4f46\u662f\u542b\u4e49\u4e0d\u4e00\u6837\u3002<\/span><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#333333\">a&#043;1\u8868\u793a\u7b2c\u4e8c\u884c\u7684\u5730\u5740&#xff0c;\u5176\u6570\u503c\u548c\u7b2c\u4e8c\u884c\u7b2c\u4e00\u5217\u7684\u5730\u5740\u5373&amp;a[1][0]\u4e00\u6837&#xff0c;\u4f46\u662f\u542b\u4e49\u4e0d\u4e00\u6837\u3002<\/span><\/p>\n<p style=\"text-align:justify\"><span style=\"color:#333333\">2. \u5217\u5730\u5740<\/span><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#333333\">\u5728\u4e8c\u7ef4\u6570\u7ec4\u4e2da[0]\u8868\u793a\u7b2c\u4e00\u884c\u7b2c\u4e00\u5217\u7684\u5730\u5740&#xff0c;\u5373\u7b49\u4ef7\u4e8e&amp;a[0][0]&#xff0c;\u6216\u8005\u5728\u6570\u7ec4\u540d\u524d\u9762\u52a0*\u8868\u793a\u964d\u7ea7\u4e3a\u5217\u5730\u5740&#xff0c;\u4e5f\u5c31\u662f*a\u8868\u793a\u7b2c\u4e00\u884c\u7b2c\u4e00\u5217\u7684\u5730\u5740&#xff0c;\u90a3\u4e48\u7b2c\u4e00\u884c\u7b2c\u4e8c\u5217\u7684\u5730\u5740\u5c31\u662f*a&#043;1<\/span><\/p>\n<p style=\"margin-left:0;margin-right:0;text-align:justify\"><span style=\"color:#333333\">\u53ef\u4ee5\u8bb0\u4f4f\u4ee5\u4e0b\u4e09\u4e2a\u5217\u5730\u5740\u7684\u65b9\u6cd5&#xff1a;<\/span><span style=\"background-color:#ffff00\"><span style=\"color:#ff0000\">&amp;a[i][j]\u3001<\/span><\/span><span style=\"background-color:#ffff00\"><span style=\"color:#ff0000\">a[i]&#043;j\u3001<\/span><\/span><span style=\"background-color:#ffff00\"><span style=\"color:#ff0000\">*(a&#043;i)&#043;j<\/span><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. \u6570\u7ec4\u7684\u57fa\u672c\u7528\u6cd51.1 \u6982\u5ff5\u6570\u7ec4(array)\u662f\u6709\u5e8f\u7684\u5143\u7d20\u5e8f\u5217\u82e5\u5c06\u6709\u9650\u4e2a\u7c7b\u578b\u76f8\u540c\u7684\u53d8\u91cf\u7684\u96c6\u5408\u547d\u540d&#xff0c;\u90a3\u4e48\u8fd9\u4e2a\u540d\u79f0\u4e3a\u6570\u7ec4\u540d\u3002\u91cd\u70b9\u5fc5\u987b\u7c7b\u578b\u76f8\u540c\u548c\u8fde\u7eed\u7684\u53d8\u91cf\u7684\u96c6\u54081.2 \u683c\u5f0f\u5b58\u50a8\u7c7b\u578b \u6570\u636e\u7c7b\u578b \u6570\u7ec4\u540d[\u5143\u7d20\u4e2a\u6570];<br \/>\n\u4f8b\u5982&#xff1a;(auto) int a[5]; \/\/ \u8fd9\u4e2aauto\u7684\u5176\u4e2d\u4e00\u79cd\u5b58\u50a8\u7c7b\u578b&#xff0c;\u901a\u5e38\u7701\u7565\u4e0d\u5199&#xff0c;\u540e\u9762\u4f1a\u5b66\u5230\u6570\u7ec4\u540d&#xff1a;\u4ee3\u8868\u6570\u7ec4\u7684\u9996\u5730\u5740(\u5373\u7b2c\u4e00\u4e2a\u5143\u7d20\u7684\u5730\u5740)&#xff0c;a\u662f\u5730\u5740\u5e38\u91cf&#xff0c;\u4e0d\u80fd\u4e3a<\/p>\n","protected":false},"author":2,"featured_media":119048,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[174,190,3712],"topic":[],"class_list":["post-119050","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-c","tag-190","tag-3712"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>C\u8bed\u8a00\uff1a\u6570\u7ec4 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/119050.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"C\u8bed\u8a00\uff1a\u6570\u7ec4 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"1. \u6570\u7ec4\u7684\u57fa\u672c\u7528\u6cd51.1 \u6982\u5ff5\u6570\u7ec4(array)\u662f\u6709\u5e8f\u7684\u5143\u7d20\u5e8f\u5217\u82e5\u5c06\u6709\u9650\u4e2a\u7c7b\u578b\u76f8\u540c\u7684\u53d8\u91cf\u7684\u96c6\u5408\u547d\u540d&#xff0c;\u90a3\u4e48\u8fd9\u4e2a\u540d\u79f0\u4e3a\u6570\u7ec4\u540d\u3002\u91cd\u70b9\u5fc5\u987b\u7c7b\u578b\u76f8\u540c\u548c\u8fde\u7eed\u7684\u53d8\u91cf\u7684\u96c6\u54081.2 \u683c\u5f0f\u5b58\u50a8\u7c7b\u578b \u6570\u636e\u7c7b\u578b \u6570\u7ec4\u540d[\u5143\u7d20\u4e2a\u6570]; \u4f8b\u5982&#xff1a;(auto) int a[5]; \/\/ \u8fd9\u4e2aauto\u7684\u5176\u4e2d\u4e00\u79cd\u5b58\u50a8\u7c7b\u578b&#xff0c;\u901a\u5e38\u7701\u7565\u4e0d\u5199&#xff0c;\u540e\u9762\u4f1a\u5b66\u5230\u6570\u7ec4\u540d&#xff1a;\u4ee3\u8868\u6570\u7ec4\u7684\u9996\u5730\u5740(\u5373\u7b2c\u4e00\u4e2a\u5143\u7d20\u7684\u5730\u5740)&#xff0c;a\u662f\u5730\u5740\u5e38\u91cf&#xff0c;\u4e0d\u80fd\u4e3a\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/119050.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-28T12:24:57+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261028122455-6ae1e99785f9a.gif\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/119050.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/119050.html\",\"name\":\"C\u8bed\u8a00\uff1a\u6570\u7ec4 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-10-28T12:24:57+00:00\",\"dateModified\":\"2026-10-28T12:24:57+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/119050.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/119050.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/119050.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"C\u8bed\u8a00\uff1a\u6570\u7ec4\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"C\u8bed\u8a00\uff1a\u6570\u7ec4 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/119050.html","og_locale":"zh_CN","og_type":"article","og_title":"C\u8bed\u8a00\uff1a\u6570\u7ec4 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"1. \u6570\u7ec4\u7684\u57fa\u672c\u7528\u6cd51.1 \u6982\u5ff5\u6570\u7ec4(array)\u662f\u6709\u5e8f\u7684\u5143\u7d20\u5e8f\u5217\u82e5\u5c06\u6709\u9650\u4e2a\u7c7b\u578b\u76f8\u540c\u7684\u53d8\u91cf\u7684\u96c6\u5408\u547d\u540d&#xff0c;\u90a3\u4e48\u8fd9\u4e2a\u540d\u79f0\u4e3a\u6570\u7ec4\u540d\u3002\u91cd\u70b9\u5fc5\u987b\u7c7b\u578b\u76f8\u540c\u548c\u8fde\u7eed\u7684\u53d8\u91cf\u7684\u96c6\u54081.2 \u683c\u5f0f\u5b58\u50a8\u7c7b\u578b \u6570\u636e\u7c7b\u578b \u6570\u7ec4\u540d[\u5143\u7d20\u4e2a\u6570]; \u4f8b\u5982&#xff1a;(auto) int a[5]; \/\/ \u8fd9\u4e2aauto\u7684\u5176\u4e2d\u4e00\u79cd\u5b58\u50a8\u7c7b\u578b&#xff0c;\u901a\u5e38\u7701\u7565\u4e0d\u5199&#xff0c;\u540e\u9762\u4f1a\u5b66\u5230\u6570\u7ec4\u540d&#xff1a;\u4ee3\u8868\u6570\u7ec4\u7684\u9996\u5730\u5740(\u5373\u7b2c\u4e00\u4e2a\u5143\u7d20\u7684\u5730\u5740)&#xff0c;a\u662f\u5730\u5740\u5e38\u91cf&#xff0c;\u4e0d\u80fd\u4e3a","og_url":"https:\/\/www.wsisp.com\/helps\/119050.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-10-28T12:24:57+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261028122455-6ae1e99785f9a.gif"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"5 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/119050.html","url":"https:\/\/www.wsisp.com\/helps\/119050.html","name":"C\u8bed\u8a00\uff1a\u6570\u7ec4 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-10-28T12:24:57+00:00","dateModified":"2026-10-28T12:24:57+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/119050.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/119050.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/119050.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"C\u8bed\u8a00\uff1a\u6570\u7ec4"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/119050","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=119050"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/119050\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/119048"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=119050"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=119050"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=119050"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=119050"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}