{"id":119688,"date":"2026-10-30T06:16:32","date_gmt":"2026-10-29T22:16:32","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/119688.html"},"modified":"2026-10-30T06:16:32","modified_gmt":"2026-10-29T22:16:32","slug":"%e7%ac%ac%e4%b9%9d%e7%ab%a0-%e7%bb%93%e6%9e%84%e4%bd%93%e3%80%81%e6%9e%9a%e4%b8%be%e7%b1%bb%e5%9e%8b%e5%92%8c%e9%93%be%e8%a1%a8","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/119688.html","title":{"rendered":"\u7b2c\u4e5d\u7ae0 \u7ed3\u6784\u4f53\u3001\u679a\u4e3e\u7c7b\u578b\u548c\u94fe\u8868"},"content":{"rendered":"<h2>\u7b2c\u4e5d\u7ae0 \u7ed3\u6784\u4f53\u3001\u679a\u4e3e\u7c7b\u578b\u548c\u94fe\u8868<\/h2>\n<h3>1. \u7ed3\u6784\u4f53<\/h3>\n<h4>1.1 \u9879\u76ee\u5f15\u5165-\u6210\u7ee9\u7cfb\u7edf\u7b2c\u4e8c\u6b21\u6539\u7248<\/h4>\n<p>\u5148\u628a\u51fa\u4e8b\u90a3\u7248\u644a\u5f00\u3002\u4e09\u4e2a\u6570\u7ec4\u5e76\u6392&#xff0c;\u52a0\u4e2a\u73ed\u7ea7\u5b57\u6bb5\u4e4b\u540e\u957f\u8fd9\u6837\u3002<\/p>\n<p>#include &lt;iostream&gt;<br \/>\n#include &lt;string&gt;<br \/>\nusing namespace std;<\/p>\n<p>int main() {<br \/>\n    string names[5] &#061; { &#034;\u5f20\u4e09&#034;, &#034;\u674e\u56db&#034;, &#034;\u738b\u4e94&#034;, &#034;\u8d75\u516d&#034;, &#034;\u5b59\u4e03&#034; };<br \/>\n    int scores[5] &#061; { 78, 92, 55, 100, 88 };<br \/>\n    int classes[5] &#061; { 1, 2, 1, 2, 1 };<\/p>\n<p>    for (int i &#061; 0; i &lt; 5; i&#043;&#043;) {<br \/>\n        cout &lt;&lt; names[i] &lt;&lt; &#034; &#034; &lt;&lt; classes[i] &lt;&lt; &#034;\u73ed &#034;<br \/>\n             &lt;&lt; scores[i] &lt;&lt; &#034;\u5206&#034; &lt;&lt; endl;<br \/>\n    }<br \/>\n    return 0;<br \/>\n}<\/p>\n<p>\u8dd1\u8d77\u6765\u4e00\u5207\u6b63\u5e38\u3002\u95ee\u9898\u4e0d\u5728\u80fd\u8dd1&#xff0c;\u5728\u4e09\u4e2a\u6570\u7ec4\u7684\u5173\u7cfb\u53ea\u5b58\u5728\u4e8e\u5199\u4ee3\u7801\u7684\u4eba\u8111\u5b50\u91cc\u3002\u54ea\u5929\u52a0\u4e2a\u5bb6\u957f\u7535\u8bdd&#xff0c;\u5c31\u662f\u7b2c\u56db\u6761\u961f\u3002<\/p>\n<p>\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510<br \/>\n\u2502 \u5e76\u884c\u6570\u7ec4\u7684\u6697\u7ebf                      \u2502<br \/>\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524<br \/>\n\u2502 \u4e24\u6761\u961f&#xff0c;\u4e00\u6761\u770b\u4e0d\u89c1\u7684\u7ebf              \u2502<br \/>\n\u2502                                     \u2502<br \/>\n\u2502   \u5e76\u6392\u7684\u4e24\u6761\u961f                      \u2502<br \/>\n\u2502                                     \u2502<br \/>\n\u2502   \u540d\u5b57\u961f         \u5206\u6570\u961f             \u2502<br \/>\n\u2502   &#043;&#8212;&#043;&#8212;&#043;&#8212;&#043;  &#043;&#8212;&#043;&#8212;&#043;&#8212;&#043;      \u2502<br \/>\n\u2502   | \u5f20 | \u674e | \u738b |  |78 |92 |55 |   \u2502<br \/>\n\u2502   &#043;&#8212;&#043;&#8212;&#043;&#8212;&#043;  &#043;&#8212;&#043;&#8212;&#043;&#8212;&#043;      \u2502<br \/>\n\u2502      ^               ^              \u2502<br \/>\n\u2502      &#043;&#8212;&#8211; \u9760\u4f60\u8bb0 &#8212;&#8211;&#043;           \u2502<br \/>\n\u2502                                     \u2502<br \/>\n\u2502   \u4e0b\u6807\u5bf9\u9f50\u5168\u51ed\u81ea\u89c9&#xff0c;\u52a0\u4e2a\u73ed\u7ea7\u5b57\u6bb5    \u2502<br \/>\n\u2502   \u5c31\u5f97\u518d\u7275\u4e00\u6761&#xff0c;\u7ebf\u8d8a\u591a\u8d8a\u5bb9\u6613\u9519      \u2502<br \/>\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518<\/p>\n<p>\u7ed3\u6784\u4f53\u7684\u601d\u8def\u4e00\u53e5\u8bdd&#xff0c;\u628a\u4e00\u6761\u8bb0\u5f55\u710a\u6210\u4e00\u4e2a\u6574\u4f53\u3002\u540d\u5b57\u3001\u73ed\u7ea7\u3001\u5206\u6570\u88c5\u8fdb\u540c\u4e00\u4e2a\u683c\u5b50&#xff0c;\u5173\u7cfb\u548c\u5b57\u6bb5\u90fd\u5199\u8fdb\u4ee3\u7801\u91cc&#xff0c;\u4e0d\u7528\u4eba\u8111\u7275\u7ebf\u3002<\/p>\n<p>#include &lt;iostream&gt;<br \/>\n#include &lt;string&gt;<br \/>\nusing namespace std;<\/p>\n<p>struct Student {<br \/>\n    string name;<br \/>\n    int grade;<br \/>\n    int score;<br \/>\n};<\/p>\n<p>int main() {<br \/>\n    Student stu[5] &#061; {<br \/>\n        { &#034;\u5f20\u4e09&#034;, 1, 78 },<br \/>\n        { &#034;\u674e\u56db&#034;, 2, 92 },<br \/>\n        { &#034;\u738b\u4e94&#034;, 1, 55 },<br \/>\n        { &#034;\u8d75\u516d&#034;, 2, 100 },<br \/>\n        { &#034;\u5b59\u4e03&#034;, 1, 88 },<br \/>\n    };<\/p>\n<p>    for (int i &#061; 0; i &lt; 5; i&#043;&#043;) {<br \/>\n        cout &lt;&lt; stu[i].name &lt;&lt; &#034; &#034; &lt;&lt; stu[i].grade &lt;&lt; &#034;\u73ed &#034;<br \/>\n             &lt;&lt; stu[i].score &lt;&lt; &#034;\u5206&#034; &lt;&lt; endl;<br \/>\n    }<br \/>\n    return 0;<br \/>\n}<\/p>\n<p>\u4e09\u6761\u961f\u53d8\u6210\u4e00\u6761\u961f&#xff0c;\u4e00\u4e2a\u683c\u5b50\u4f4f\u4e09\u6837\u4e1c\u897f\u3002\u60f3\u52a0\u5bb6\u957f\u7535\u8bdd&#xff0c;\u5f80 struct \u91cc\u52a0\u4e00\u884c&#xff0c;\u522b\u5904\u4e0d\u52a8\u3002\u6392\u5e8f\u4e5f\u7b80\u5355\u4e86&#xff0c;\u4ea4\u6362\u6574\u4e2a Student&#xff0c;\u540d\u5b57\u73ed\u7ea7\u5206\u6570\u6346\u5728\u4e00\u8d77\u8d70&#xff0c;\u4e0d\u5b58\u5728\u7275\u9519\u7ebf\u3002<\/p>\n<p>\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510<br \/>\n\u2502 \u4e09\u6761\u961f\u5e76\u6210\u4e00\u6761\u961f                            \u2502<br \/>\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524<br \/>\n\u2502 \u4e00\u683c\u4f4f\u4e09\u6837&#xff0c;\u4e0d\u7528\u518d\u7275\u7ebf                      \u2502<br \/>\n\u2502                                             \u2502<br \/>\n\u2502   struct Student {                          \u2502<br \/>\n\u2502       string name;                          \u2502<br \/>\n\u2502       int score;                            \u2502<br \/>\n\u2502   };                                        \u2502<br \/>\n\u2502                                             \u2502<br \/>\n\u2502 &#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;&#043;   \u2502<br \/>\n\u2502 |\u5199\u6cd5              |\u53d6\u5230\u7684\u4e1c\u897f          |   \u2502<br \/>\n\u2502 &#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;&#043;   \u2502<br \/>\n\u2502 |stu[0].name       |\u7b2c\u4e00\u4e2a\u4eba\u7684\u540d\u5b57      |   \u2502<br \/>\n\u2502 |stu[0].score      |\u7b2c\u4e00\u4e2a\u4eba\u7684\u5206\u6570      |   \u2502<br \/>\n\u2502 |stu[2].score      |\u7b2c\u4e09\u4e2a\u4eba\u7684\u5206\u6570      |   \u2502<br \/>\n\u2502 &#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;&#043;   \u2502<br \/>\n\u2502                                             \u2502<br \/>\n\u2502   \u540d\u5b57\u548c\u5206\u6570\u88c5\u8fdb\u540c\u4e00\u4e2a\u683c\u5b50                  \u2502<br \/>\n\u2502   \u5173\u7cfb\u4e0d\u7528\u518d\u9760\u4eba\u8111\u8bb0                        \u2502<br \/>\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518<\/p>\n<h4>1.2 struct \u7684\u5b9a\u4e49\u4e0e\u521d\u59cb\u5316<\/h4>\n<p>struct \u7684\u5199\u6cd5\u56fa\u5b9a&#xff0c;struct \u52a0\u540d\u5b57&#xff0c;\u4e00\u5bf9\u82b1\u62ec\u53f7&#xff0c;\u5b57\u6bb5\u6328\u4e2a\u58f0\u660e&#xff0c;\u5206\u53f7\u6536\u5c3e\u3002\u5b57\u6bb5\u7684\u7c7b\u578b\u53ef\u4ee5\u662f\u5b66\u8fc7\u7684\u4efb\u4f55\u4e00\u79cd&#xff0c;\u4e5f\u53ef\u4ee5\u8fd8\u662f\u7ed3\u6784\u4f53\u3002<\/p>\n<p>struct Student {<br \/>\n    string name;<br \/>\n    int grade;<br \/>\n    int score;<br \/>\n};<\/p>\n<p>\u8bb0\u4f4f\u5b9a\u4e49\u672b\u5c3e\u90a3\u4e2a\u5206\u53f7\u3002\u82b1\u62ec\u53f7\u540e\u9762\u6f0f\u4e86\u5b83&#xff0c;\u7f16\u8bd1\u5668\u62a5\u9519\u7684\u4f4d\u7f6e\u80fd\u98d8\u5230\u4e0b\u4e00\u884c&#xff0c;\u7b2c\u4e00\u6b21\u89c1\u5bb9\u6613\u53d1\u61f5\u3002<\/p>\n<p>\u521d\u59cb\u5316\u8ddf\u7740\u6570\u7ec4\u5b66&#xff0c;\u4e00\u4e32\u82b1\u62ec\u53f7\u6309\u987a\u5e8f\u5bf9\u4f4d\u3002<\/p>\n<p>Student a &#061; { &#034;\u5f20\u4e09&#034;, 1, 78 };        \/\/ \u4e09\u4e2a\u5b57\u6bb5\u5168\u7ed9<br \/>\nStudent b { &#034;\u674e\u56db&#034;, 2, 92 };          \/\/ \u7b49\u53f7\u7701\u7565\u4e5f\u884c<br \/>\nStudent c &#061; { &#034;\u738b\u4e94&#034;, 1 };            \/\/ \u53ea\u7ed9\u524d\u4e24\u4e2a&#xff0c;\u7b2c\u4e09\u4e2a\u8865\u96f6<br \/>\nStudent d;                            \/\/ \u4e00\u4e2a\u4e0d\u7ed9&#xff0c;\u91cc\u9762\u662f\u5783\u573e\u503c<\/p>\n<p>\u53ea\u7ed9\u4e00\u90e8\u5206&#xff0c;\u5269\u4e0b\u7684\u81ea\u52a8\u8865\u96f6&#xff0c;\u548c\u6570\u7ec4\u4e00\u4e2a\u813e\u6c14\u3002\u4e00\u4e2a\u4e0d\u7ed9\u7684\u90a3\u79cd&#xff0c;score \u91cc\u662f\u5185\u5b58\u6b8b\u7559&#xff0c;\u8bfb\u51fa\u6765\u662f\u4ec0\u4e48\u6570\u5168\u770b\u8fd0\u6c14&#xff0c;\u7528\u4e4b\u524d\u52a1\u5fc5\u5148\u8d4b\u503c\u3002C&#043;&#043;11 \u8d77\u8fd8\u80fd\u7f3a\u7701\u5b57\u6bb5\u503c&#xff0c;\u5199\u5728\u5b9a\u4e49\u91cc&#xff0c;\u521d\u59cb\u5316\u65f6\u53ef\u4ee5\u4e0d\u5199\u3002<\/p>\n<p>struct Student {<br \/>\n    string name;<br \/>\n    int grade &#061; 1;<br \/>\n    int score &#061; 0;<br \/>\n};<\/p>\n<p>Student e &#061; { &#034;\u8d75\u516d&#034; };               \/\/ grade \u662f 1&#xff0c;score \u662f 0<\/p>\n<h4>1.3 \u6210\u5458\u8bbf\u95ee&#xff0c;\u70b9\u53f7\u548c\u7bad\u5934<\/h4>\n<p>\u7ed3\u6784\u4f53\u53d8\u91cf\u53d6\u6210\u5458\u7528\u70b9\u53f7&#xff0c;\u6307\u9488\u53d6\u6210\u5458\u7528\u7bad\u5934\u3002<\/p>\n<p>#include &lt;iostream&gt;<br \/>\n#include &lt;string&gt;<br \/>\nusing namespace std;<\/p>\n<p>struct Student {<br \/>\n    string name;<br \/>\n    int score;<br \/>\n};<\/p>\n<p>int main() {<br \/>\n    Student stu &#061; { &#034;\u5f20\u4e09&#034;, 78 };<br \/>\n    Student *p &#061; &amp;stu;<\/p>\n<p>    cout &lt;&lt; stu.name &lt;&lt; &#034; &#034; &lt;&lt; stu.score &lt;&lt; endl;   \/\/ \u5f20\u4e09 78<br \/>\n    cout &lt;&lt; p-&gt;name &lt;&lt; &#034; &#034; &lt;&lt; p-&gt;score &lt;&lt; endl;     \/\/ \u5f20\u4e09 78<br \/>\n    cout &lt;&lt; (*p).name &lt;&lt; endl;                      \/\/ \u5f20\u4e09<\/p>\n<p>    stu.score &#061; 90;<br \/>\n    cout &lt;&lt; p-&gt;score &lt;&lt; endl;                       \/\/ 90<\/p>\n<p>    return 0;<br \/>\n}<\/p>\n<p>\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510<br \/>\n\u2502 \u4e00\u4e2a\u683c\u5b50\u4f4f\u4e24\u4e2a\u5b57\u6bb5                     \u2502<br \/>\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524<br \/>\n\u2502 \u6210\u5458\u6309\u58f0\u660e\u987a\u5e8f\u6392                       \u2502<br \/>\n\u2502                                        \u2502<br \/>\n\u2502 \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510   \u2502<br \/>\n\u2502 \u2502struct Point { int x; int y; };   \u2502   \u2502<br \/>\n\u2502 \u2502&#043;&#8212;&#8212;&#8211;&#043;&#8212;&#8212;&#8211;&#043;               \u2502   \u2502<br \/>\n\u2502 \u2502|   x    |   y    |               \u2502   \u2502<br \/>\n\u2502 \u2502&#043;&#8212;&#8212;&#8211;&#043;&#8212;&#8212;&#8211;&#043;               \u2502   \u2502<br \/>\n\u2502 \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518   \u2502<br \/>\n\u2502                                        \u2502<br \/>\n\u2502   \u5e38\u89c1\u5e73\u53f0\u4e0a\u4e24\u4e2a int \u5171\u516b\u5b57\u8282          \u2502<br \/>\n\u2502   Student \u91cc\u542b string&#xff0c;\u591a\u5927\u770b\u5b9e\u73b0      \u2502<br \/>\n\u2502   \u6210\u5458\u6309\u58f0\u660e\u987a\u5e8f\u6392&#xff0c;\u4e2d\u95f4\u53ef\u80fd\u8865\u9f50       \u2502<br \/>\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518<\/p>\n<p>\u70b9\u53f7\u548c\u7bad\u5934\u662f\u4e00\u6761\u8def\u3002p-&gt;score \u5c31\u662f (*p).score \u7684\u7f29\u5199&#xff0c;\u4e24\u6761\u7ebf\u4e00\u56de\u4e8b&#xff0c;\u7bad\u5934\u7eaf\u7cb9\u5c11\u6253\u51e0\u4e2a\u5b57\u3002\u6307\u9488\u6539\u6210\u5458&#xff0c;\u539f\u53d8\u91cf\u8ddf\u7740\u53d8&#xff0c;\u7b2c\u516d\u7ae0\u89e3\u5f15\u7528\u7684\u89c4\u77e9\u5728\u8fd9\u63a5\u7740\u7528\u3002<\/p>\n<h4>1.4 \u7ed3\u6784\u4f53\u6570\u7ec4\u4e0e\u5d4c\u5957<\/h4>\n<p>\u7ed3\u6784\u4f53\u6570\u7ec4\u5c31\u662f\u4e00\u6761\u961f&#xff0c;\u6bcf\u683c\u4f4f\u4e00\u4e2a\u5b8c\u6574\u8bb0\u5f55&#xff0c;\u4e0a\u4e00\u8282\u7684 Student stu[5] \u5df2\u7ecf\u662f\u4e86\u3002\u53d6\u7b2c i \u4e2a\u4eba\u7684\u5206\u6570&#xff0c;stu[i].score&#xff0c;\u4e0b\u6807\u548c\u70b9\u53f7\u8fde\u7528&#xff0c;\u5148\u6311\u683c\u5b50\u518d\u53d6\u5b57\u6bb5\u3002<\/p>\n<p>\u7ed3\u6784\u4f53\u5957\u7ed3\u6784\u4f53\u4e5f\u81ea\u7136&#xff0c;\u5b57\u6bb5\u7684\u7c7b\u578b\u53ef\u4ee5\u662f\u53e6\u4e00\u4e2a\u7ed3\u6784\u4f53\u3002<\/p>\n<p>#include &lt;iostream&gt;<br \/>\n#include &lt;string&gt;<br \/>\nusing namespace std;<\/p>\n<p>struct Date {<br \/>\n    int year;<br \/>\n    int month;<br \/>\n    int day;<br \/>\n};<\/p>\n<p>struct Student {<br \/>\n    string name;<br \/>\n    Date birthday;<br \/>\n    int score;<br \/>\n};<\/p>\n<p>int main() {<br \/>\n    Student stu &#061; { &#034;\u5f20\u4e09&#034;, { 2005, 9, 1 }, 78 };<\/p>\n<p>    cout &lt;&lt; stu.name &lt;&lt; &#034; &#034; &lt;&lt; stu.birthday.year &lt;&lt; &#034;\u5e74&#034;<br \/>\n         &lt;&lt; stu.birthday.month &lt;&lt; &#034;\u6708&#034; &lt;&lt; stu.birthday.day &lt;&lt; &#034;\u65e5 &#034;<br \/>\n         &lt;&lt; stu.score &lt;&lt; &#034;\u5206&#034; &lt;&lt; endl;<\/p>\n<p>    return 0;<br \/>\n}<\/p>\n<p>\u70b9\u53f7\u53ef\u4ee5\u8fde\u7740\u5199&#xff0c;stu.birthday.year \u4e00\u5c42\u5c42\u5f80\u91cc\u8d70\u3002\u5d4c\u5957\u522b\u8d2a\u6df1&#xff0c;\u4e24\u5c42\u591f\u7528&#xff0c;\u4e09\u5c42\u4ee5\u4e0a\u8bfb\u8d77\u6765\u8d39\u52b2&#xff0c;\u8be5\u62c6\u7684\u65f6\u5019\u62c6\u3002<\/p>\n<p>\u5185\u5b58\u91cc\u5b57\u6bb5\u6309\u58f0\u660e\u987a\u5e8f\u6392&#xff0c;\u7f16\u8bd1\u5668\u53ef\u80fd\u5728\u4e2d\u95f4\u585e\u8865\u9f50\u5b57\u8282\u3002\u770b\u4e2a\u5e72\u51c0\u7684&#xff0c;\u4e24\u4e2a int \u7684\u7ed3\u6784\u4f53&#xff0c;\u5e38\u89c1\u5e73\u53f0\u4e0a\u5360\u516b\u5b57\u8282&#xff0c;\u4e24\u4e2a\u5b57\u6bb5\u6328\u7740\u5750\u3002<\/p>\n<p>\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510<br \/>\n\u2502 \u70b9\u53f7\u548c\u7bad\u5934                                      \u2502<br \/>\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524<br \/>\n\u2502 \u53d8\u91cf\u7528\u70b9&#xff0c;\u6307\u9488\u7528\u7bad\u5934                            \u2502<br \/>\n\u2502                                                 \u2502<br \/>\n\u2502 &#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;&#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&#043;   \u2502<br \/>\n\u2502 |\u624b\u4e0a\u662f\u4ec0\u4e48          |\u8bbf\u95ee\u6210\u5458\u7684\u5199\u6cd5        |   \u2502<br \/>\n\u2502 &#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;&#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&#043;   \u2502<br \/>\n\u2502 |Student \u53d8\u91cf        |stu.name              |   \u2502<br \/>\n\u2502 |Student \u6307\u9488        |p-&gt;name               |   \u2502<br \/>\n\u2502 |\u60f3\u7528\u70b9\u7684\u573a\u5408        |(*p).name \u4e5f\u5bf9        |   \u2502<br \/>\n\u2502 &#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;&#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&#043;   \u2502<br \/>\n\u2502                                                 \u2502<br \/>\n\u2502   \u7bad\u5934\u662f\u70b9\u7684\u7f29\u5199&#xff0c;\u4e24\u6761\u7ebf\u4e00\u56de\u4e8b                  \u2502<br \/>\n\u2502   -&gt; \u524d\u9762\u5fc5\u987b\u662f\u4e2a\u5730\u5740                           \u2502<br \/>\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518<\/p>\n<h4>1.5 \u5185\u5b58\u5bf9\u9f50&#xff0c;8 \u5bf9 12<\/h4>\n<p>\u540c\u6837\u4e09\u4e2a\u5b57\u6bb5&#xff0c;\u6362\u4e2a\u987a\u5e8f\u6392&#xff0c;\u5360\u5730\u80fd\u5dee\u4e00\u534a\u3002\u8fd9\u4e0d\u662f\u7f16\u8bd1\u5668\u62a0\u95e8&#xff0c;\u662f\u5bf9\u9f50\u5728\u7ba1\u4e8b\u3002int \u7231\u5750\u5728\u56db\u7684\u500d\u6570\u5730\u5740\u4e0a&#xff0c;char \u54ea\u513f\u90fd\u80fd\u5750\u3002struct A \u91cc\u4e24\u4e2a char \u6324\u5728\u524d\u5934&#xff0c;\u8865\u9f50\u4e24\u5b57\u8282&#xff0c;int \u5750\u7b2c\u56db\u683c\u8d77&#xff0c;\u603b\u5171\u516b\u5b57\u8282\u3002struct B \u91cc char \u5750\u7b2c\u4e00\u683c&#xff0c;int \u5f97\u632a\u5230\u7b2c\u4e94\u683c\u8d77&#xff0c;\u672b\u5c3e\u90a3\u4e2a char \u540e\u9762\u8fd8\u5f97\u518d\u8865\u4e09\u5b57\u8282&#xff0c;\u603b\u5171\u5341\u4e8c\u5b57\u8282\u3002<\/p>\n<p>\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510<br \/>\n\u2502 \u8865\u9f50\u7684\u7a7a\u5730                                 \u2502<br \/>\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524<br \/>\n\u2502 \u540c\u6837\u4e09\u4e2a\u5b57\u6bb5&#xff0c;\u6392\u6cd5\u4e0d\u540c\u5360\u5730\u5dee\u4e00\u534a           \u2502<br \/>\n\u2502                                            \u2502<br \/>\n\u2502   struct A { char c1; char c2; int n; };   \u2502<br \/>\n\u2502   &#043;&#8211;&#043;&#8211;&#043;&#8211;&#043;&#8211;&#043;&#8211;&#043;&#8211;&#043;&#8211;&#043;&#8211;&#043;                \u2502<br \/>\n\u2502   |c1|c2|\u8865|\u8865|    n     |                 \u2502<br \/>\n\u2502   &#043;&#8211;&#043;&#8211;&#043;&#8211;&#043;&#8211;&#043;&#8211;&#043;&#8211;&#043;&#8211;&#043;&#8211;&#043;                \u2502<br \/>\n\u2502                                            \u2502<br \/>\n\u2502   struct B { char c1; int n; char c2; };   \u2502<br \/>\n\u2502   &#043;&#8211;&#043;&#8211;&#043;&#8211;&#043;&#8211;&#043;&#8211;&#043;&#8211;&#043;&#8211;&#043;&#8211;&#043;&#8211;&#043;&#8211;&#043;&#8211;&#043;&#8211;&#043;    \u2502<br \/>\n\u2502   |c1|\u8865|\u8865|\u8865|    n     |c2|\u8865|\u8865|\u8865|     \u2502<br \/>\n\u2502   &#043;&#8211;&#043;&#8211;&#043;&#8211;&#043;&#8211;&#043;&#8211;&#043;&#8211;&#043;&#8211;&#043;&#8211;&#043;&#8211;&#043;&#8211;&#043;&#8211;&#043;&#8211;&#043;    \u2502<br \/>\n\u2502                                            \u2502<br \/>\n\u2502   \u516b\u5b57\u8282\u5bf9\u5341\u4e8c\u5b57\u8282&#xff0c;\u8865\u9f50\u7684\u7a7a\u5730\u5360\u7740\u4e0d\u7528     \u2502<br \/>\n\u2502   \u5927\u7684\u5148\u58f0\u660e&#xff0c;\u5c0f\u7684\u968f\u540e\u8ddf                   \u2502<br \/>\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518<\/p>\n<p>\u4ee3\u7801\u91cc\u4e0d\u7528\u80cc\u89c4\u5219&#xff0c;\u8bb0\u4f4f\u4e00\u6761\u5c31\u591f&#xff0c;\u5b57\u6bb5\u6309\u5927\u5c0f\u4ece\u5927\u5230\u5c0f\u58f0\u660e&#xff0c;char \u653e\u4e00\u5806&#xff0c;int \u653e\u4e00\u5806&#xff0c;string \u653e\u6700\u524d&#xff0c;\u8865\u9f50\u7684\u7a7a\u5730\u80fd\u5c11\u4e00\u5927\u5757\u3002sizeof \u968f\u65f6\u95ee&#xff0c;\u522b\u731c\u3002<\/p>\n<p>#include &lt;iostream&gt;<br \/>\nusing namespace std;<\/p>\n<p>struct A { char c1; char c2; int n; };<br \/>\nstruct B { char c1; int n; char c2; };<br \/>\nstruct C { int n; char c1; char c2; };<\/p>\n<p>int main() {<br \/>\n    cout &lt;&lt; sizeof(A) &lt;&lt; &#034; &#034; &lt;&lt; sizeof(B) &lt;&lt; &#034; &#034; &lt;&lt; sizeof(C) &lt;&lt; endl;<br \/>\n    return 0;<br \/>\n}<\/p>\n<p>\u5e38\u89c1\u5e73\u53f0\u8f93\u51fa 8 12 8\u3002A \u548c C \u5b57\u6bb5\u4e00\u6a21\u4e00\u6837&#xff0c;\u53ea\u6362\u4e86\u987a\u5e8f&#xff0c;\u4e00\u6837\u5927\u3002B \u767d\u767d\u80d6\u51fa\u56db\u5b57\u8282\u3002\u8fd9\u662f\u884c\u4e3a\u8ddf\u5e73\u53f0\u8d70&#xff0c;\u6362\u53f0\u673a\u5668\u53ef\u80fd\u4e0d\u540c&#xff0c;sizeof \u81ea\u5df1\u95ee\u624d\u4f5c\u6570\u3002<\/p>\n<h4>1.6 \u7ed3\u6784\u4f53\u8fdb\u51fd\u6570<\/h4>\n<p>\u7ed3\u6784\u4f53\u5f53\u53c2\u6570&#xff0c;\u7b2c\u4e03\u7ae0\u90a3\u4e09\u6761\u8def\u539f\u6837\u9002\u7528&#xff0c;\u503c\u4f20\u9012\u3001\u6307\u9488\u3001\u5f15\u7528\u3002Student \u8fd9\u79cd\u4e2a\u5934\u5927\u7684&#xff0c;\u503c\u4f20\u9012\u8981\u6574\u4efd\u62f7\u8d1d&#xff0c;\u80fd\u7701\u5219\u7701\u3002<\/p>\n<p>#include &lt;iostream&gt;<br \/>\n#include &lt;string&gt;<br \/>\nusing namespace std;<\/p>\n<p>struct Student {<br \/>\n    string name;<br \/>\n    int score;<br \/>\n};<\/p>\n<p>void printByValue(Student s) {<br \/>\n    cout &lt;&lt; s.name &lt;&lt; &#034; &#034; &lt;&lt; s.score &lt;&lt; endl;<br \/>\n}<\/p>\n<p>void raise(Student *p, int delta) {<br \/>\n    p-&gt;score &#043;&#061; delta;<br \/>\n}<\/p>\n<p>void show(const Student &amp;s) {<br \/>\n    cout &lt;&lt; s.name &lt;&lt; &#034; &#034; &lt;&lt; s.score &lt;&lt; endl;<br \/>\n}<\/p>\n<p>int main() {<br \/>\n    Student stu &#061; { &#034;\u5f20\u4e09&#034;, 78 };<\/p>\n<p>    printByValue(stu);        \/\/ \u5f20\u4e09 78&#xff0c;\u526f\u672c\u6539\u4e0d\u52a8\u539f\u503c<br \/>\n    raise(&amp;stu, 5);           \/\/ \u5f20\u4e09 83<br \/>\n    show(stu);                \/\/ \u5f20\u4e09 83<\/p>\n<p>    return 0;<br \/>\n}<\/p>\n<p>\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510<br \/>\n\u2502 \u8fc7\u95e8\u7684\u89c4\u77e9                                           \u2502<br \/>\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524<br \/>\n\u2502 \u4e00\u6761\u6570\u636e\u8fc7\u95e8&#xff0c;\u4e09\u6761\u8def                                 \u2502<br \/>\n\u2502                                                      \u2502<br \/>\n\u2502 &#043;&#8212;&#8212;&#8212;&#8212;&#8212;-&#043;&#8212;&#8212;&#8212;&#8212;&#8212;-&#043;&#8212;&#8212;&#8212;&#8212;&#8211;&#043;   \u2502<br \/>\n\u2502 |\u5199\u6cd5            |\u5f62\u53c2\u62ff\u5230\u5565      |\u6539\u5f97\u52a8\u5417      |   \u2502<br \/>\n\u2502 &#043;&#8212;&#8212;&#8212;&#8212;&#8212;-&#043;&#8212;&#8212;&#8212;&#8212;&#8212;-&#043;&#8212;&#8212;&#8212;&#8212;&#8211;&#043;   \u2502<br \/>\n\u2502 |Student s       |\u6574\u4efd\u62f7\u8d1d        |\u6539\u7684\u662f\u526f\u672c    |   \u2502<br \/>\n\u2502 |Student *p      |\u4e00\u4e2a\u5730\u5740        |\u6539\u5f97\u4e86        |   \u2502<br \/>\n\u2502 |const Student &amp;s|\u539f\u6570\u636e\u7684\u522b\u540d    |\u53ea\u8bfb          |   \u2502<br \/>\n\u2502 &#043;&#8212;&#8212;&#8212;&#8212;&#8212;-&#043;&#8212;&#8212;&#8212;&#8212;&#8212;-&#043;&#8212;&#8212;&#8212;&#8212;&#8211;&#043;   \u2502<br \/>\n\u2502                                                      \u2502<br \/>\n\u2502   \u5c0f\u7684\u4f20\u503c\u7701\u5fc3&#xff0c;\u5927\u7684\u4f20\u5f15\u7528                           \u2502<br \/>\n\u2502   \u4e0d\u78b0\u539f\u6570\u636e&#xff0c;const \u710a\u6b7b\u5728\u524d\u9762                       \u2502<br \/>\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518<\/p>\n<p>\u53ea\u8bfb\u7684\u573a\u5408&#xff0c;const Student &amp;s \u662f\u9996\u9009&#xff0c;\u4e0d\u62f7\u8d1d\u53c8\u78b0\u4e0d\u4e86\u539f\u6570\u636e\u3002\u8981\u6539\u7684\u573a\u5408&#xff0c;\u5f15\u7528\u548c\u6307\u9488\u90fd\u884c&#xff0c;\u7b2c\u4e03\u7ae0\u8bb2\u8fc7\u600e\u4e48\u6311&#xff0c;\u5c0f\u6570\u636e\u503c\u4f20\u9012&#xff0c;\u8981\u6539\u6570\u636e\u7528\u5f15\u7528\u3002\u7ed3\u6784\u4f53\u8fd8\u80fd\u5f53\u8fd4\u56de\u503c&#xff0c;return \u4e00\u4e2a Student \u56de\u53bb&#xff0c;\u8c03\u7528\u70b9\u63a5\u4f4f&#xff0c;\u7b2c\u4e03\u7ae0\u8bf4\u8fc7\u7684\u62f7\u8d1d\u89c4\u77e9\u4e00\u6837\u7ba1\u3002<\/p>\n<h3>2. \u679a\u4e3e\u7c7b\u578b<\/h3>\n<h4>2.1 0 1 2 \u8bf4\u4e0d\u6e05<\/h4>\n<p>\u72b6\u6001\u8fd9\u79cd\u5b57\u6bb5&#xff0c;\u65b0\u624b\u6700\u7231\u62ff\u5c0f\u6574\u6570\u51d1\u30020 \u662f\u5f85\u673a&#xff0c;1 \u662f\u8fd0\u884c&#xff0c;2 \u662f\u505c\u673a&#xff0c;\u5199\u8d77\u6765\u5feb&#xff0c;\u4e09\u4e2a\u6708\u540e\u6ca1\u4eba\u8ba4\u5f97\u3002<\/p>\n<p>int state &#061; 0;<br \/>\nif (state &#061;&#061; 0) { \/* \u5e72\u4ec0\u4e48 *\/ }<br \/>\nif (state &#061;&#061; 1) { \/* \u5e72\u4ec0\u4e48 *\/ }<\/p>\n<p>\u4ee3\u7801\u5f53\u65f6\u770b\u5f97\u61c2&#xff0c;\u9694\u5929\u5c31\u7cca\u6d82\u30020 \u662f\u4ec0\u4e48\u72b6\u6001&#xff0c;1 \u53c8\u662f\u4ec0\u4e48\u72b6\u6001&#xff0c;\u7ffb\u5b9a\u4e49\u7ffb\u5230\u773c\u82b1\u3002\u66f4\u9669\u7684\u662f\u62fc\u5199&#xff0c;state &#061;&#061; 3 \u662f\u4ec0\u4e48&#xff0c;\u7f16\u8bd1\u5668\u4e0d\u7ba1&#xff0c;\u8dd1\u51fa\u602a\u73b0\u8c61\u6162\u6162\u67e5\u3002<\/p>\n<p>\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510<br \/>\n\u2502 \u6570\u5b57\u6ca1\u540d\u5b57                                        \u2502<br \/>\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524<br \/>\n\u2502 0 1 2 \u662f\u8c01\u7684\u5929\u4e0b                                  \u2502<br \/>\n\u2502                                                   \u2502<br \/>\n\u2502 &#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;&#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#043;   \u2502<br \/>\n\u2502 |\u4ee3\u7801\u91cc              |\u4e09\u4e2a\u6708\u540e                |   \u2502<br \/>\n\u2502 &#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;&#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#043;   \u2502<br \/>\n\u2502 |if (state &#061;&#061; 0)     |0 \u662f\u4ec0\u4e48\u72b6\u6001            |   \u2502<br \/>\n\u2502 |if (state &#061;&#061; 1)     |1 \u53c8\u662f\u4ec0\u4e48\u72b6\u6001          |   \u2502<br \/>\n\u2502 |if (state &#061;&#061; 2)     |\u7ffb\u5b9a\u4e49\u53bb&#xff0c;\u7d2f            |   \u2502<br \/>\n\u2502 &#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;&#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#043;   \u2502<br \/>\n\u2502                                                   \u2502<br \/>\n\u2502   \u6362\u6210\u540d\u5b57\u5199&#xff0c;\u4ee3\u7801\u81ea\u5df1\u4f1a\u8bf4\u8bdd                      \u2502<br \/>\n\u2502   \u540d\u5b57\u9876\u66ff\u6570\u5b57&#xff0c;\u9519\u62fc\u7f16\u8bd1\u5668\u5c31\u62e6                    \u2502<br \/>\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518<\/p>\n<p>\u679a\u4e3e\u5c31\u662f\u7ed9\u6570\u5b57\u4e0a\u6237\u53e3\u3002\u7ed9\u6bcf\u4e2a\u6570\u8d77\u4e2a\u540d\u5b57&#xff0c;\u4ee3\u7801\u81ea\u5df1\u4f1a\u8bf4\u8bdd\u3002<\/p>\n<p>enum State { IDLE, RUNNING, STOPPED };<\/p>\n<p>State s &#061; RUNNING;<br \/>\nif (s &#061;&#061; RUNNING) { \/* \u5e72\u4ec0\u4e48 *\/ }<\/p>\n<p>\u540d\u5b57\u9876\u66ff\u6570\u5b57&#xff0c;\u9519\u62fc\u4e00\u4e2a\u5b57\u6bcd\u7f16\u8bd1\u5668\u5c31\u62e6\u4e0b&#xff0c;\u8fd9\u6bd4\u9ed8\u9ed8\u8dd1\u9519\u5f3a\u592a\u591a\u3002<\/p>\n<h4>2.2 enum \u7684\u57fa\u672c\u7528\u6cd5<\/h4>\n<p>\u5b9a\u4e49\u4e00\u6761\u679a\u4e3e&#xff0c;enum \u52a0\u540d\u5b57&#xff0c;\u82b1\u62ec\u53f7\u91cc\u5217\u540d\u5b57&#xff0c;\u9017\u53f7\u9694\u5f00&#xff0c;\u5206\u53f7\u6536\u5c3e\u3002<\/p>\n<p>enum Color { RED, GREEN, BLUE };<\/p>\n<p>\u4e0d\u5199\u503c\u65f6\u4ece 0 \u8d77\u81ea\u52a8\u7f16\u53f7&#xff0c;RED \u662f 0&#xff0c;GREEN \u662f 1&#xff0c;BLUE \u662f 2\u3002\u53ef\u4ee5\u6307\u5b9a\u4ece\u54ea\u513f\u8d77\u5934&#xff0c;\u4e5f\u53ef\u4ee5\u53ea\u7ed9\u4e2d\u95f4\u7684\u3002<\/p>\n<p>enum Level { LOW &#061; 1, MID &#061; 5, HIGH &#061; 10 };   \/\/ LOW 1&#xff0c;MID 5&#xff0c;HIGH 10<br \/>\nenum Err { OK, WARN &#061; 100, FATAL };           \/\/ OK 0&#xff0c;WARN 100&#xff0c;FATAL 101<\/p>\n<p>\u540e\u9762\u7684\u503c\u8ddf\u7740\u524d\u4e00\u4e2a\u8d70&#xff0c;FATAL \u662f 101&#xff0c;\u4e0d\u662f 2\u3002\u8fd9\u70b9\u5bb9\u6613\u770b\u8d70\u773c&#xff0c;\u7f16\u53f7\u4e0d\u4e00\u5b9a\u8fde\u7eed\u3002<\/p>\n<p>\u679a\u4e3e\u53d8\u91cf\u4e4b\u95f4\u80fd\u6bd4\u5927\u5c0f&#xff0c;switch \u91cc\u4e5f\u80fd\u7528&#xff0c;\u7b2c\u4e03\u7ae0\u7684 switch \u914d\u5b83\u6b63\u5408\u9002\u3002<\/p>\n<p>#include &lt;iostream&gt;<br \/>\nusing namespace std;<\/p>\n<p>enum Level { LOW &#061; 1, MID &#061; 5, HIGH &#061; 10 };<\/p>\n<p>int main() {<br \/>\n    Level lv &#061; HIGH;<\/p>\n<p>    switch (lv) {<br \/>\n        case LOW:  cout &lt;&lt; &#034;\u4f4e&#034; &lt;&lt; endl; break;<br \/>\n        case MID:  cout &lt;&lt; &#034;\u4e2d&#034; &lt;&lt; endl; break;<br \/>\n        case HIGH: cout &lt;&lt; &#034;\u9ad8&#034; &lt;&lt; endl; break;<br \/>\n    }<\/p>\n<p>    cout &lt;&lt; (MID &lt; HIGH) &lt;&lt; endl;    \/\/ 1<\/p>\n<p>    return 0;<br \/>\n}<\/p>\n<p>\u8001\u5f0f enum \u6709\u4e2a\u6bdb\u75c5&#xff0c;\u540d\u5b57\u76f4\u633a\u633a\u8eba\u5728\u5916\u5c42\u4f5c\u7528\u57df&#xff0c;\u548c\u522b\u7684\u679a\u4e3e\u649e\u540d\u7b97\u51b2\u7a81\u3002\u4e24\u4e2a enum \u90fd\u6709 RED&#xff0c;\u7f16\u8bd1\u5668\u76f4\u63a5\u62e6\u3002C&#043;&#043;11 \u9001\u6765 enum class&#xff0c;\u628a\u540d\u5b57\u6536\u8fdb\u679a\u4e3e\u81ea\u5df1\u5bb6\u91cc\u3002<\/p>\n<h4>2.3 enum class<\/h4>\n<p>enum class Color { RED, GREEN, BLUE };<br \/>\nenum class Week { Mon, Tue, Wed };<\/p>\n<p>Color c &#061; Color::RED;         \/\/ \u5f97\u62a5\u6e05\u5bb6\u95e8<br \/>\nWeek d &#061; Week::Mon;<\/p>\n<p>\u5fc5\u987b\u5e26\u524d\u7f00 Color::RED&#xff0c;Week::Mon\u3002\u540d\u5b57\u5f52\u81ea\u5df1\u7ba1&#xff0c;\u649e\u4e0d\u5230\u522b\u4eba\u3002\u8fd8\u6709\u4e2a\u597d\u5904&#xff0c;\u4e0d\u4f1a\u5077\u5077\u8f6c\u6210 int&#xff0c;\u548c\u8001\u5f0f enum \u5212\u6e05\u754c\u9650\u3002<\/p>\n<p>#include &lt;iostream&gt;<br \/>\nusing namespace std;<\/p>\n<p>enum class Week { Mon, Tue, Wed };<\/p>\n<p>int main() {<br \/>\n    Week d &#061; Week::Mon;<\/p>\n<p>    cout &lt;&lt; static_cast&lt;int&gt;(d) &lt;&lt; endl;    \/\/ 0<\/p>\n<p>    \/\/ cout &lt;&lt; d &lt;&lt; endl;                   \/\/ \u7f16\u8bd1\u4e0d\u8fc7&#xff0c;\u4e0d\u8ba9\u76f4\u63a5\u8f93\u51fa<br \/>\n    \/\/ if (d &#061;&#061; 1) { }                      \/\/ \u7f16\u8bd1\u4e0d\u8fc7&#xff0c;\u4e0d\u548c int \u6bd4<\/p>\n<p>    return 0;<br \/>\n}<\/p>\n<p>\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510<br \/>\n\u2502 \u679a\u4e3e\u4e09\u79cd\u8138                                        \u2502<br \/>\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524<br \/>\n\u2502 \u8001\u5199\u6cd5\u65b0\u5199\u6cd5&#xff0c;\u4e00\u5802\u8bfe\u8ba4\u5168                          \u2502<br \/>\n\u2502                                                   \u2502<br \/>\n\u2502 &#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&#043;   \u2502<br \/>\n\u2502 |\u5199\u6cd5                  |\u957f\u76f8                  |   \u2502<br \/>\n\u2502 &#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&#043;   \u2502<br \/>\n\u2502 |enum Color            |RED GREEN BLUE        |   \u2502<br \/>\n\u2502 |enum Level            |LOW&#061;1 MID&#061;5 HIGH&#061;10   |   \u2502<br \/>\n\u2502 |enum class Week       |Mon Tue Wed           |   \u2502<br \/>\n\u2502 &#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&#043;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-&#043;   \u2502<br \/>\n\u2502                                                   \u2502<br \/>\n\u2502   \u4e0d\u5e26 class&#xff0c;\u540d\u5b57\u76f4\u633a\u633a\u8eba\u5728\u5916\u5c42                  \u2502<br \/>\n\u2502   \u5e26 class&#xff0c;\u5f97\u62a5\u6e05 Week \u5bb6\u95e8                      \u2502<br \/>\n\u2502   \u65b0\u5de5\u7a0b\u8d77\u624b\u5c31\u4e0a class \u7248                         \u2502<br \/>\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518<\/p>\n<p>\u60f3\u8f93\u51fa\u5f97 static_cast \u8f6c\u4e00\u4e0b&#xff0c;\u60f3\u6bd4\u8f83\u5f97\u62ff\u679a\u4e3e\u4e4b\u95f4\u5bf9\u3002\u5570\u55e6\u662f\u5570\u55e6&#xff0c;\u6362\u6765\u7684\u662f type \u5b89\u5168&#xff0c;\u503c\u4f20\u9519\u4e86\u7f16\u8bd1\u5668\u5f53\u573a\u62e6\u3002\u65b0\u4ee3\u7801\u4f18\u5148 enum class&#xff0c;\u8001\u4ee3\u7801\u91cc\u8ba4\u5f97\u51fa\u8001\u5199\u6cd5\u5c31\u884c\u3002<\/p>\n<h3>3. \u94fe\u8868<\/h3>\n<h4>3.1 \u6570\u7ec4\u7684\u786c\u4f24<\/h4>\n<p>\u6570\u7ec4\u662f\u6761\u961f&#xff0c;\u4e00\u683c\u6328\u4e00\u683c\u3002\u4e2d\u95f4\u63d2\u4e00\u4e2a\u4eba&#xff0c;\u540e\u9762\u5168\u4f53\u642c\u5bb6\u3002\u4e94\u4e2a\u4eba\u7684\u961f\u8fd8\u597d&#xff0c;\u4e94\u4e07\u4eba\u7684\u961f&#xff0c;\u63d2\u4e00\u6b21\u642c\u4e94\u4e07\u683c\u3002<\/p>\n<p>\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510<br \/>\n\u2502 \u6570\u7ec4\u7684\u642c\u5bb6\u8d39                             \u2502<br \/>\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524<br \/>\n\u2502 \u63d2\u961f\u5bb9\u6613&#xff0c;\u642c\u5bb6\u8d39\u5413\u4eba                     \u2502<br \/>\n\u2502                                          \u2502<br \/>\n\u2502   \u6570\u7ec4  78 92 55 100 88                  \u2502<br \/>\n\u2502   \u8981\u5728\u4e0b\u6807 1 \u63d2\u4e2a 90                     \u2502<br \/>\n\u2502                                          \u2502<br \/>\n\u2502   \u7b2c\u4e00\u6b65  \u4ece\u540e\u5f80\u524d&#xff0c;88 100 55 \u4f9d\u6b21\u53f3\u79fb   \u2502<br \/>\n\u2502   \u7b2c\u4e8c\u6b65  90 \u843d\u8fdb\u4e0b\u6807 1 \u7a7a\u51fa\u6765\u7684\u4f4d       \u2502<br \/>\n\u2502                                          \u2502<br \/>\n\u2502   \u4e00\u4e2a\u4eba\u8fdb\u573a&#xff0c;\u4e09\u4e2a\u4eba\u632a\u7a9d                 \u2502<br \/>\n\u2502   \u4eba\u591a\u65f6\u5019&#xff0c;\u8fd9\u7b14\u642c\u8fd0\u8d39\u5413\u4eba               \u2502<br \/>\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518<\/p>\n<p>\u5220\u4eba\u4e5f\u4e00\u6837&#xff0c;\u4e2d\u95f4\u6316\u8d70\u4e00\u4e2a&#xff0c;\u540e\u9762\u96c6\u4f53\u524d\u79fb\u3002\u8fd9\u4e9b\u642c\u8fd0\u8d39&#xff0c;\u94fe\u8868\u4e00\u5206\u4e0d\u82b1\u3002\u94fe\u8868\u662f\u4e00\u8282\u4e00\u8282\u8f66\u53a2&#xff0c;\u7528\u6307\u9488\u4e32\u8d77\u6765&#xff0c;\u4e2d\u95f4\u63a5\u4e00\u8282\u53ea\u6539\u4e24\u6839\u7ebf\u3002<\/p>\n<p>\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510<br \/>\n\u2502 \u8f66\u53a2\u7684\u6a21\u6837                               \u2502<br \/>\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524<br \/>\n\u2502 \u4e00\u8282\u8f66\u53a2\u4e24\u6837\u4e1c\u897f                         \u2502<br \/>\n\u2502                                          \u2502<br \/>\n\u2502 \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510   \u2502<br \/>\n\u2502 \u2502Node                                \u2502   \u2502<br \/>\n\u2502 \u2502  &#043;&#8212;&#8212;&#8211;&#043;&#8212;&#8212;&#8211;&#043;               \u2502   \u2502<br \/>\n\u2502 \u2502  |  data  |  next  |               \u2502   \u2502<br \/>\n\u2502 \u2502  &#043;&#8212;&#8212;&#8211;&#043;&#8212;&#8212;&#8211;&#043;               \u2502   \u2502<br \/>\n\u2502 \u2502   \u5b58\u6570\u636e    \u5b58\u4e0b\u4e00\u8282\u7684\u5730\u5740         \u2502   \u2502<br \/>\n\u2502 \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518   \u2502<br \/>\n\u2502                                          \u2502<br \/>\n\u2502   \u6700\u540e\u4e00\u8282\u7684 next \u653e\u7a7a\u6307\u9488               \u2502<br \/>\n\u2502   \u7a7a\u6307\u9488\u662f\u8fd9\u6761\u7ebf\u7684\u7ec8\u70b9\u7ad9                 \u2502<br \/>\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518<\/p>\n<h4>3.2 \u8282\u70b9\u957f\u4ec0\u4e48\u6837<\/h4>\n<p>\u94fe\u8868\u7684\u57fa\u672c\u5355\u5143\u53eb\u8282\u70b9&#xff0c;\u4e00\u4e2a\u8282\u70b9\u88c5\u4e24\u6837\u4e1c\u897f&#xff0c;\u81ea\u5df1\u7684\u6570\u636e&#xff0c;\u548c\u4e0b\u4e00\u8282\u7684\u5730\u5740\u3002<\/p>\n<p>struct Node {<br \/>\n    int data;<br \/>\n    Node *next;<br \/>\n};<\/p>\n<p>\u7ed3\u6784\u4f53\u91cc\u51fa\u73b0\u6307\u5411\u81ea\u5df1\u7684\u6307\u9488&#xff0c;\u8fd9\u53eb\u81ea\u5f15\u7528&#xff0c;\u5408\u6cd5\u4e14\u5e38\u89c1\u3002\u6700\u540e\u4e00\u8282\u7684 next \u4e0d\u653e\u5730\u5740&#xff0c;\u653e\u7a7a\u6307\u9488 nullptr&#xff0c;\u5f53\u7ec8\u70b9\u7ad9\u3002C&#043;&#043;11 \u8d77\u7a7a\u6307\u9488\u5199 nullptr&#xff0c;\u7b2c\u516d\u7ae0\u7528\u8fc7\u3002<\/p>\n<p>\u642d\u94fe\u5c31\u662f\u8ba9\u4e00\u8282\u4e00\u8282\u7684 next \u6307\u4e0b\u53bb\u3002\u5934\u63d2\u6cd5&#xff0c;\u65b0\u8282\u70b9\u5f80\u961f\u5934\u585e&#xff0c;\u5c3e\u63d2\u6cd5&#xff0c;\u65b0\u8282\u70b9\u5f80\u961f\u5c3e\u63a5\u3002<\/p>\n<p>#include &lt;iostream&gt;<br \/>\nusing namespace std;<\/p>\n<p>struct Node {<br \/>\n    int data;<br \/>\n    Node *next;<br \/>\n};<\/p>\n<p>int main() {<br \/>\n    Node *head &#061; nullptr;<\/p>\n<p>    \/\/ \u5c3e\u63d2 1 2 3<br \/>\n    Node *tail &#061; nullptr;<br \/>\n    for (int i &#061; 1; i &lt;&#061; 3; i&#043;&#043;) {<br \/>\n        Node *p &#061; new Node;<br \/>\n        p-&gt;data &#061; i;<br \/>\n        p-&gt;next &#061; nullptr;<br \/>\n        if (head &#061;&#061; nullptr) {<br \/>\n            head &#061; p;<br \/>\n        } else {<br \/>\n            tail-&gt;next &#061; p;<br \/>\n        }<br \/>\n        tail &#061; p;<br \/>\n    }<\/p>\n<p>    \/\/ \u987a\u7740 next \u8d70\u4e00\u904d<br \/>\n    for (Node *p &#061; head; p !&#061; nullptr; p &#061; p-&gt;next) {<br \/>\n        cout &lt;&lt; p-&gt;data &lt;&lt; &#034; &#034;;          \/\/ 1 2 3<br \/>\n    }<br \/>\n    cout &lt;&lt; endl;<\/p>\n<p>    return 0;<br \/>\n}<\/p>\n<p>\u8f93\u51fa 1 2 3\u3002\u5c3e\u63d2\u4fdd\u5e8f&#xff0c;\u5148\u8fdb\u5148\u51fa\u3002\u6ce8\u610f new \u51fa\u6765\u7684\u8282\u70b9&#xff0c;\u5faa\u73af\u91cc\u9010\u4e2a\u8981&#xff0c;\u7a0b\u5e8f\u9000\u51fa\u524d\u4e0d delete \u5c31\u662f\u6cc4\u6f0f&#xff0c;\u4e0b\u4e00\u8282\u6536\u62fe\u3002<\/p>\n<p>\u904d\u5386\u7684\u5199\u6cd5\u5c31\u4e00\u53e5&#xff0c;for (Node *p &#061; head; p !&#061; nullptr; p &#061; p-&gt;next)\u3002\u4ece head \u51fa\u53d1&#xff0c;\u987a\u7740 next \u4e00\u8def\u8d70&#xff0c;\u8d70\u5230\u7a7a\u6307\u9488\u505c\u3002\u8fd9\u53e5\u662f\u94fe\u8868\u7684\u603b\u673a\u5173&#xff0c;\u63d2\u5220\u67e5\u627e\u90fd\u957f\u5728\u5b83\u8eab\u4e0a\u3002<\/p>\n<h4>3.3 \u5934\u63d2\u4e0e\u904d\u5386<\/h4>\n<p>\u5934\u63d2\u6cd5\u66f4\u7701\u4e8b&#xff0c;\u4e0d\u7528\u8bb0 tail\u3002\u65b0\u8282\u70b9\u7684 next \u5148\u6307\u5411\u65e7\u5934&#xff0c;head \u518d\u6539\u6307\u65b0\u8282\u70b9&#xff0c;\u4e24\u6b65\u3002<\/p>\n<p>Node *head &#061; nullptr;<\/p>\n<p>for (int i &#061; 1; i &lt;&#061; 3; i&#043;&#043;) {<br \/>\n    Node *p &#061; new Node;<br \/>\n    p-&gt;data &#061; i;<br \/>\n    p-&gt;next &#061; head;      \/\/ \u65b0\u8282\u70b9\u6307\u5411\u65e7\u5934<br \/>\n    head &#061; p;            \/\/ \u5934\u6307\u9488\u6539\u6307\u65b0\u8282\u70b9<br \/>\n}<\/p>\n<p>for (Node *p &#061; head; p !&#061; nullptr; p &#061; p-&gt;next) {<br \/>\n    cout &lt;&lt; p-&gt;data &lt;&lt; &#034; &#034;;          \/\/ 3 2 1<br \/>\n}<br \/>\ncout &lt;&lt; endl;<\/p>\n<p>\u8f93\u51fa 3 2 1&#xff0c;\u540e\u6765\u7684\u7ad9\u524d\u9762&#xff0c;\u540e\u8fdb\u5148\u51fa\u3002\u4e24\u6b65\u6709\u987a\u5e8f\u8bb2\u7a76&#xff0c;p-&gt;next &#061; head \u5fc5\u987b\u5148\u505a&#xff0c;\u5148\u628a\u65e7\u5934\u7684\u5730\u5740\u5b58\u4e0b\u6765&#xff0c;\u518d\u8ba9 head \u6539\u6307\u3002\u987a\u5e8f\u53cd\u4e86&#xff0c;\u65e7\u5934\u7684\u5730\u5740\u4e00\u4e22&#xff0c;\u6574\u6761\u94fe\u65ad\u5728\u540e\u9762\u3002<\/p>\n<p>\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510<br \/>\n\u2502 \u94fe\u8868\u53ea\u52a8\u7ebf                             \u2502<br \/>\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524<br \/>\n\u2502 \u94fe\u8868\u53ea\u6539\u4e24\u6839\u7ebf                         \u2502<br \/>\n\u2502                                        \u2502<br \/>\n\u2502 \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510   \u2502<br \/>\n\u2502 \u2502  \u65b0\u8282\u70b9 90                       \u2502   \u2502<br \/>\n\u2502 \u2502    next &#8211;&gt; 92 \u90a3\u95f4\u623f            \u2502   \u2502<br \/>\n\u2502 \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518   \u2502<br \/>\n\u2502   78 \u90a3\u95f4\u623f\u7684 next &#8211;&gt; \u65b0\u8282\u70b9          \u2502<br \/>\n\u2502                                        \u2502<br \/>\n\u2502   \u4e00\u4e2a\u4eba\u7684\u8fdb\u573a\u8d39&#xff0c;\u4e24\u6839\u7ebf               \u2502<br \/>\n\u2502   \u540e\u9762\u7684\u4eba\u539f\u5730\u4e0d\u52a8                     \u2502<br \/>\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518<\/p>\n<h4>3.4 \u5220\u9664\u4e0e\u91ca\u653e<\/h4>\n<p>\u5220\u9664\u8981\u5206\u4e24\u5934\u3002\u961f\u5934\u597d\u5220&#xff0c;head \u5f80\u524d\u63a8\u4e00\u683c\u5c31\u884c&#xff0c;\u6536\u5de5\u90a3\u4e2a while \u5e72\u7684\u5c31\u662f\u8fd9\u4e8b\u3002\u961f\u4e2d\u95f4\u5f97\u5148\u627e\u5230\u524d\u4e00\u4e2a&#xff0c;\u8ba9\u524d\u4e00\u4e2a\u7684 next \u8de8\u8fc7\u5b83&#xff0c;\u518d delete\u3002<\/p>\n<p>#include &lt;iostream&gt;<br \/>\nusing namespace std;<\/p>\n<p>struct Node {<br \/>\n    int data;<br \/>\n    Node *next;<br \/>\n};<\/p>\n<p>int main() {<br \/>\n    Node *head &#061; nullptr;<br \/>\n    for (int i &#061; 1; i &lt;&#061; 3; i&#043;&#043;) {<br \/>\n        Node *p &#061; new Node;<br \/>\n        p-&gt;data &#061; i;<br \/>\n        p-&gt;next &#061; head;<br \/>\n        head &#061; p;<br \/>\n    }<br \/>\n    \/\/ \u6b64\u65f6\u94fe\u662f 3 2 1<\/p>\n<p>    \/\/ \u5220\u4e2d\u95f4\u7684 2&#xff0c;\u5148\u627e\u5230\u5b83\u524d\u9762\u7684 3<br \/>\n    Node *prev &#061; head;                    \/\/ 3<br \/>\n    Node *cur &#061; head-&gt;next;               \/\/ 2<br \/>\n    prev-&gt;next &#061; cur-&gt;next;               \/\/ 3 \u7684 next \u6539\u6307 1<br \/>\n    delete cur;                           \/\/ \u91ca\u653e 2<\/p>\n<p>    for (Node *p &#061; head; p !&#061; nullptr; p &#061; p-&gt;next) {<br \/>\n        cout &lt;&lt; p-&gt;data &lt;&lt; &#034; &#034;;           \/\/ 3 1<br \/>\n    }<br \/>\n    cout &lt;&lt; endl;<\/p>\n<p>    \/\/ \u6536\u5de5&#xff0c;\u5269\u4e0b\u7684\u9010\u4e2a\u91ca\u653e&#xff0c;\u6bcf\u8f6e\u90fd\u662f\u5220\u961f\u5934<br \/>\n    while (head !&#061; nullptr) {<br \/>\n        Node *p &#061; head;<br \/>\n        head &#061; head-&gt;next;<br \/>\n        delete p;<br \/>\n    }<\/p>\n<p>    return 0;<br \/>\n}<\/p>\n<p>\u8f93\u51fa 3 1\u3002\u5220\u4e2d\u95f4\u8282\u70b9\u4e09\u6b65&#xff0c;\u627e\u5230\u524d\u4e00\u4e2a&#xff0c;\u8ba9\u524d\u4e00\u4e2a\u7684 next \u8de8\u8fc7\u5b83&#xff0c;delete \u5b83\u3002\u987a\u5e8f\u4e0d\u80fd\u53cd&#xff0c;\u5148 delete \u518d\u8de8\u7ebf&#xff0c;\u90a3\u6761\u7ebf\u6307\u7740\u5df2\u7ecf\u91ca\u653e\u7684\u5185\u5b58&#xff0c;\u8e29\u4e0b\u53bb\u662f\u4ec0\u4e48\u5168\u770b\u9020\u5316\u3002<\/p>\n<p>\u6536\u5c3e\u90a3\u4e2a while \u662f\u94fe\u8868\u7a0b\u5e8f\u7684\u6807\u914d&#xff0c;\u4ece\u5934\u5f00\u59cb\u9010\u4e2a delete&#xff0c;head \u4e00\u8def\u5f80\u524d\u63a8\u3002\u7b2c\u516d\u7ae0\u8bf4\u8fc7&#xff0c;new \u51fa\u6765\u7684\u5185\u5b58\u6d3b\u5230 delete \u90a3\u4e00\u523b&#xff0c;\u94fe\u8868\u8fd9\u7ae0\u5c24\u5176\u8981\u76ef\u7d27&#xff0c;\u4e00\u8282\u4e0d\u6f0f\u624d\u53eb\u6536\u5de5\u3002<\/p>\n<h4>3.5 \u94fe\u8868\u7684\u4ee3\u4ef7<\/h4>\n<p>\u94fe\u8868\u4e0d\u662f\u514d\u8d39\u5348\u9910&#xff0c;\u7701\u4e86\u642c\u5bb6\u8d39&#xff0c;\u53e6\u6709\u4e24\u7b14\u6210\u672c\u3002<\/p>\n<p>\u7b2c\u4e00\u7b14&#xff0c;\u4e0d\u80fd\u968f\u673a\u8bbf\u95ee\u3002\u6570\u7ec4 a[3] \u4e00\u6b65\u5230\u4f4d&#xff0c;\u94fe\u8868\u5f97\u4ece head \u6570\u4e09\u8282\u3002\u627e\u7b2c i \u4e2a\u662f O(i)&#xff0c;\u6570\u7ec4\u662f O(1)\u3002\u6309\u4f4d\u7f6e\u53cd\u590d\u53d6\u7684\u573a\u5408&#xff0c;\u6570\u7ec4\u8d62\u3002<\/p>\n<p>\u7b2c\u4e8c\u7b14&#xff0c;\u7f13\u5b58\u4e0d\u53cb\u597d\u3002\u6570\u7ec4\u5728\u5185\u5b58\u91cc\u8fde\u7eed\u6392&#xff0c;\u7f13\u5b58\u4e00\u6b21\u642c\u4e00\u5927\u6bb5&#xff0c;\u7b2c\u516d\u7ae0\u63d0\u8fc7\u3002\u94fe\u8868\u7684\u8282\u6563\u5728\u5404\u5904&#xff0c;next \u6307\u54ea\u513f\u7b97\u54ea\u513f&#xff0c;\u8df3\u7740\u626b\u7f13\u5b58\u5403\u4e8f\u3002<\/p>\n<p>\u6240\u4ee5\u9009\u62e9\u9898\u5f88\u7b80\u5355&#xff0c;\u6570\u636e\u5b9a\u957f\u3001\u6309\u4f4d\u7f6e\u53d6&#xff0c;\u7528\u6570\u7ec4&#xff1b;\u6570\u636e\u589e\u51cf\u9891\u7e41\u3001\u4e2a\u5934\u4e0d\u5b9a&#xff0c;\u7528\u94fe\u8868\u3002\u5b9e\u9645\u5de5\u7a0b\u91cc\u624b\u5199\u94fe\u8868\u7684\u673a\u4f1a\u4e0d\u591a&#xff0c;\u6807\u51c6\u5e93\u7684 list\u3001vector \u90fd\u662f\u66f4\u597d\u7528\u7684\u6210\u54c1&#xff0c;\u7b2c\u5341\u7ae0\u4e4b\u540e\u9646\u7eed\u89c1\u3002\u94fe\u8868\u7684\u4ef7\u503c\u5728\u628a\u6307\u9488\u7ec3\u719f&#xff0c;\u9762\u8bd5\u7231\u95ee&#xff0c;\u5e95\u5c42\u6570\u636e\u7ed3\u6784\u5168\u9760\u5b83\u6253\u5e95\u3002<\/p>\n<h3>4. \u5c0f\u7ed3<\/h3>\n<p>\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510<br \/>\n\u2502 \u672c\u7ae0\u6536\u53e3                     \u2502<br \/>\n\u251c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524<br \/>\n\u2502 \u4e09\u6837\u4e1c\u897f&#xff0c;\u4e00\u6761\u4e0a\u5761\u8def         \u2502<br \/>\n\u2502                              \u2502<br \/>\n\u2502   \u7ed3\u6784\u4f53  \u5173\u7cfb\u710a\u8fdb\u4ee3\u7801\u91cc     \u2502<br \/>\n\u2502   \u679a\u4e3e    \u540d\u5b57\u9876\u66ff\u6570\u5b57       \u2502<br \/>\n\u2502   \u94fe\u8868    \u7528\u6307\u9488\u4e32\u8d77\u6570\u636e     \u2502<br \/>\n\u2502                              \u2502<br \/>\n\u2502   \u7ed3\u6784\u4f53\u91cc\u585e\u8fdb\u51fd\u6570&#xff0c;\u5c31\u662f\u7c7b   \u2502<br \/>\n\u2502   \u4e0b\u4e00\u7ae0\u7c7b\u4e0e\u5bf9\u8c61&#xff0c;\u6b63\u5f0f\u5f00\u5de5   \u2502<br \/>\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518<\/p>\n<p>\u4e09\u6837\u4e1c\u897f\u4e00\u6761\u7ebf\u3002\u7ed3\u6784\u4f53\u628a\u5173\u7cfb\u710a\u8fdb\u6570\u636e&#xff0c;\u5b57\u6bb5\u6328\u4e2a\u58f0\u660e&#xff0c;\u82b1\u62ec\u53f7\u521d\u59cb\u5316&#xff0c;\u70b9\u53f7\u53d6\u6210\u5458&#xff0c;\u7bad\u5934\u914d\u6307\u9488&#xff0c;sizeof \u95ee\u5927\u5c0f&#xff0c;\u5b57\u6bb5\u6309\u5927\u5c0f\u58f0\u660e\u7701\u8865\u9f50\u3002\u4f20\u53c2\u4e09\u6761\u8def\u7167\u65e7&#xff0c;\u53ea\u8bfb\u7528 const \u5f15\u7528\u3002<\/p>\n<p>\u679a\u4e3e\u7ed9\u6570\u5b57\u4e0a\u6237\u53e3&#xff0c;\u8001\u5f0f enum \u540d\u5b57\u8eba\u5728\u5916\u5c42&#xff0c;enum class \u6536\u8fdb\u81ea\u5bb6\u95e8\u8fd8\u7981\u9690\u5f0f\u8f6c\u6362&#xff0c;\u65b0\u4ee3\u7801\u4f18\u5148 class \u7248\u3002\u94fe\u8868\u4e00\u8282\u4e24\u6837&#xff0c;data \u52a0 next&#xff0c;\u5c3e\u63d2\u4fdd\u5e8f\u5934\u63d2\u9006\u5e8f&#xff0c;\u904d\u5386\u987a\u7740 next \u8d70\u5230\u7a7a\u6307\u9488&#xff0c;\u5220\u9664\u5148\u8de8\u7ebf\u518d delete&#xff0c;\u6536\u5de5\u9010\u4e2a\u91ca\u653e\u3002<\/p>\n<p>\u94fe\u8868\u7684\u9009\u62e9\u9898\u8bb0\u4f4f\u4e24\u53e5&#xff0c;\u5b9a\u957f\u6309\u4f4d\u7f6e\u53d6\u7528\u6570\u7ec4&#xff0c;\u5e38\u589e\u5e38\u51cf\u7528\u94fe\u8868&#xff0c;\u4e0d\u80fd\u968f\u673a\u8bbf\u95ee\u548c\u7f13\u5b58\u5403\u4e8f\u662f\u5b83\u7684\u4e24\u9762\u3002<\/p>\n<p>\u4e09\u4e2a\u5e73\u53f0\u7684\u901f\u67e5\u5361\u548c\u6392\u9519\u8868\u5728\u9644\u5f55&#xff0c;\u6253\u5370\u8d34\u5899\u3002<\/p>\n<h4>\u9644\u5f55 A \u901f\u67e5\u5361<\/h4>\n<table>\n<tr>\u77e5\u8bc6\u70b9\u5199\u6cd5\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>\u5b9a\u4e49\u7ed3\u6784\u4f53<\/td>\n<td>struct S { int a; };<\/td>\n<td>\u672b\u5c3e\u5206\u53f7\u4e0d\u80fd\u5c11<\/td>\n<\/tr>\n<tr>\n<td>\u521d\u59cb\u5316<\/td>\n<td>S s &#061; { 1, 2 };<\/td>\n<td>\u7f3a\u7684\u8865\u96f6<\/td>\n<\/tr>\n<tr>\n<td>\u6210\u5458\u9ed8\u8ba4\u503c<\/td>\n<td>struct S { int a &#061; 1; };<\/td>\n<td>C&#043;&#043;11 \u8d77<\/td>\n<\/tr>\n<tr>\n<td>\u70b9\u53f7\u53d6\u6210\u5458<\/td>\n<td>s.a<\/td>\n<td>\u53d8\u91cf\u573a\u5408<\/td>\n<\/tr>\n<tr>\n<td>\u7bad\u5934\u53d6\u6210\u5458<\/td>\n<td>p-&gt;a<\/td>\n<td>\u6307\u9488\u573a\u5408<\/td>\n<\/tr>\n<tr>\n<td>\u5d4c\u5957\u521d\u59cb\u5316<\/td>\n<td>S s &#061; { 1, { 2, 3 } };<\/td>\n<td>\u4e00\u5c42\u5c42\u5bf9\u4f4d<\/td>\n<\/tr>\n<tr>\n<td>sizeof<\/td>\n<td>sizeof(S)<\/td>\n<td>\u95ee\u7f16\u8bd1\u5668&#xff0c;\u522b\u731c<\/td>\n<\/tr>\n<tr>\n<td>\u8001\u5f0f\u679a\u4e3e<\/td>\n<td>enum E { A, B };<\/td>\n<td>\u4ece 0 \u8d77<\/td>\n<\/tr>\n<tr>\n<td>\u6307\u5b9a\u7f16\u53f7<\/td>\n<td>enum E { A &#061; 1, B &#061; 5 };<\/td>\n<td>\u540e\u7eed\u8ddf\u7740\u8d70<\/td>\n<\/tr>\n<tr>\n<td>\u5f3a\u7c7b\u578b\u679a\u4e3e<\/td>\n<td>enum class E { A };<\/td>\n<td>E::A \u8bbf\u95ee&#xff0c;\u7981\u9690\u5f0f\u8f6c\u6362<\/td>\n<\/tr>\n<tr>\n<td>\u8282\u70b9\u5b9a\u4e49<\/td>\n<td>struct Node { int data; Node *next; };<\/td>\n<td>\u81ea\u5f15\u7528\u5408\u6cd5<\/td>\n<\/tr>\n<tr>\n<td>\u5efa\u7a7a\u94fe<\/td>\n<td>Node *head &#061; nullptr;<\/td>\n<td>\u7a7a\u6307\u9488\u662f\u7ec8\u70b9\u7ad9<\/td>\n<\/tr>\n<tr>\n<td>\u5934\u63d2<\/td>\n<td>p-&gt;next &#061; head; head &#061; p;<\/td>\n<td>\u987a\u5e8f\u4e0d\u80fd\u53cd<\/td>\n<\/tr>\n<tr>\n<td>\u5c3e\u63d2<\/td>\n<td>tail-&gt;next &#061; p; tail &#061; p;<\/td>\n<td>\u8981\u8bb0 tail<\/td>\n<\/tr>\n<tr>\n<td>\u904d\u5386<\/td>\n<td>for (Node *p &#061; head; p; p &#061; p-&gt;next)<\/td>\n<td>\u94fe\u8868\u603b\u673a\u5173<\/td>\n<\/tr>\n<tr>\n<td>\u5220\u4e2d\u95f4\u8282\u70b9<\/td>\n<td>prev-&gt;next &#061; cur-&gt;next; delete cur;<\/td>\n<td>\u5148\u8de8\u7ebf\u518d\u91ca\u653e<\/td>\n<\/tr>\n<tr>\n<td>\u6574\u94fe\u91ca\u653e<\/td>\n<td>while (head) { p &#061; head; head &#061; head-&gt;next; delete p; }<\/td>\n<td>\u6536\u5de5\u6807\u914d<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>\u9644\u5f55 B \u6392\u9519\u8868<\/h4>\n<table>\n<tr>\u5e38\u89c1\u73b0\u8c61\u75c5\u6839\u836f\u65b9<\/tr>\n<tbody>\n<tr>\n<td>\u62a5\u9519 expected \u5206\u53f7<\/td>\n<td>struct \u5b9a\u4e49\u672b\u5c3e\u6f0f\u5206\u53f7<\/td>\n<td>\u82b1\u62ec\u53f7\u540e\u8865\u4e0a<\/td>\n<\/tr>\n<tr>\n<td>\u6210\u5458\u662f\u5783\u573e\u503c<\/td>\n<td>\u53d8\u91cf\u6ca1\u521d\u59cb\u5316<\/td>\n<td>\u82b1\u62ec\u53f7\u7ed9\u503c&#xff0c;\u6216\u5199\u9ed8\u8ba4\u503c<\/td>\n<\/tr>\n<tr>\n<td>\u62a5\u9519 p.name \u7528\u4e0d\u4e86<\/td>\n<td>p \u662f\u6307\u9488<\/td>\n<td>\u6539 p-&gt;name \u6216 (*p).name<\/td>\n<\/tr>\n<tr>\n<td>\u4e24\u4e2a RED \u649e\u540d<\/td>\n<td>\u8001\u5f0f enum \u540d\u5b57\u5728\u5916\u5c42<\/td>\n<td>\u6362 enum class<\/td>\n<\/tr>\n<tr>\n<td>cout \u6253\u4e0d\u51fa\u679a\u4e3e<\/td>\n<td>enum class \u4e0d\u8ba9\u8f6c int<\/td>\n<td>static_cast \u4e00\u4e0b<\/td>\n<\/tr>\n<tr>\n<td>\u679a\u4e3e\u503c\u4e0d\u662f\u9884\u671f\u90a3\u4e2a<\/td>\n<td>\u6307\u5b9a\u7f16\u53f7\u540e\u8ddf\u7740\u8d70<\/td>\n<td>\u6570\u4e00\u904d\u6bcf\u4e2a\u7684\u503c<\/td>\n<\/tr>\n<tr>\n<td>sizeof \u6bd4\u60f3\u7684\u5927<\/td>\n<td>\u5bf9\u9f50\u8865\u9f50<\/td>\n<td>\u5b57\u6bb5\u6309\u5927\u5c0f\u4ece\u5927\u5230\u5c0f\u6392<\/td>\n<\/tr>\n<tr>\n<td>\u904d\u5386\u5361\u6b7b\u6216\u8bfb\u4e71<\/td>\n<td>next \u6ca1\u8d70\u5230\u7a7a\u6307\u9488<\/td>\n<td>\u67e5\u6700\u540e\u8282\u70b9\u653e\u6ca1\u653e nullptr<\/td>\n<\/tr>\n<tr>\n<td>\u5934\u63d2\u540e\u94fe\u65ad\u4e86<\/td>\n<td>next \u548c head \u987a\u5e8f\u53cd\u4e86<\/td>\n<td>\u5148\u5b58\u65e7\u5934\u518d\u6539 head<\/td>\n<\/tr>\n<tr>\n<td>\u5220\u5b8c\u8282\u70b9\u8e29\u5783\u573e<\/td>\n<td>delete \u540e\u53c8\u8bfb\u5b83<\/td>\n<td>\u5148\u8de8\u7ebf\u518d delete&#xff0c;\u8bfb\u5b8c\u518d\u91ca\u653e<\/td>\n<\/tr>\n<tr>\n<td>\u8dd1\u4e45\u4e86\u5185\u5b58\u6da8<\/td>\n<td>new \u7684\u6ca1 delete<\/td>\n<td>\u6536\u5de5 while \u9010\u4e2a\u91ca\u653e<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>\u7b2c\u4e5d\u7ae0 \u7ed3\u6784\u4f53\u3001\u679a\u4e3e\u7c7b\u578b\u548c\u94fe\u88681. \u7ed3\u6784\u4f531.1 \u9879\u76ee\u5f15\u5165-\u6210\u7ee9\u7cfb\u7edf\u7b2c\u4e8c\u6b21\u6539\u7248\u5148\u628a\u51fa\u4e8b\u90a3\u7248\u644a\u5f00\u3002\u4e09\u4e2a\u6570\u7ec4\u5e76\u6392&#xff0c;\u52a0\u4e2a\u73ed\u7ea7\u5b57\u6bb5\u4e4b\u540e\u957f\u8fd9\u6837\u3002#include<br \/>\n#include<br \/>\nusing namespace std;int main() {string names[5]  { \\&#8221;\u5f20\u4e09\\&#8221;, \\&#8221;\u674e\u56db\\&#8221;, \\&#8221;\u738b\u4e94\\&#8221;, \\&#8221;\u8d75\u516d\\&#8221;, \\&#8221;\u5b59\u4e03\\&#8221; };int scores[5]  { 78, 92, 55, 100, 88 };int cla<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[55],"topic":[],"class_list":["post-119688","post","type-post","status-publish","format-standard","hentry","category-server","tag-c"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u7b2c\u4e5d\u7ae0 \u7ed3\u6784\u4f53\u3001\u679a\u4e3e\u7c7b\u578b\u548c\u94fe\u8868 - \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\/119688.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u7b2c\u4e5d\u7ae0 \u7ed3\u6784\u4f53\u3001\u679a\u4e3e\u7c7b\u578b\u548c\u94fe\u8868 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u7b2c\u4e5d\u7ae0 \u7ed3\u6784\u4f53\u3001\u679a\u4e3e\u7c7b\u578b\u548c\u94fe\u88681. \u7ed3\u6784\u4f531.1 \u9879\u76ee\u5f15\u5165-\u6210\u7ee9\u7cfb\u7edf\u7b2c\u4e8c\u6b21\u6539\u7248\u5148\u628a\u51fa\u4e8b\u90a3\u7248\u644a\u5f00\u3002\u4e09\u4e2a\u6570\u7ec4\u5e76\u6392&#xff0c;\u52a0\u4e2a\u73ed\u7ea7\u5b57\u6bb5\u4e4b\u540e\u957f\u8fd9\u6837\u3002#include #include using namespace std;int main() {string names[5] { &quot;\u5f20\u4e09&quot;, &quot;\u674e\u56db&quot;, &quot;\u738b\u4e94&quot;, &quot;\u8d75\u516d&quot;, &quot;\u5b59\u4e03&quot; };int scores[5] { 78, 92, 55, 100, 88 };int cla\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/119688.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-29T22:16:32+00:00\" \/>\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=\"9 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/119688.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/119688.html\",\"name\":\"\u7b2c\u4e5d\u7ae0 \u7ed3\u6784\u4f53\u3001\u679a\u4e3e\u7c7b\u578b\u548c\u94fe\u8868 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-10-29T22:16:32+00:00\",\"dateModified\":\"2026-10-29T22:16:32+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/119688.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/119688.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/119688.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u7b2c\u4e5d\u7ae0 \u7ed3\u6784\u4f53\u3001\u679a\u4e3e\u7c7b\u578b\u548c\u94fe\u8868\"}]},{\"@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":"\u7b2c\u4e5d\u7ae0 \u7ed3\u6784\u4f53\u3001\u679a\u4e3e\u7c7b\u578b\u548c\u94fe\u8868 - \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\/119688.html","og_locale":"zh_CN","og_type":"article","og_title":"\u7b2c\u4e5d\u7ae0 \u7ed3\u6784\u4f53\u3001\u679a\u4e3e\u7c7b\u578b\u548c\u94fe\u8868 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u7b2c\u4e5d\u7ae0 \u7ed3\u6784\u4f53\u3001\u679a\u4e3e\u7c7b\u578b\u548c\u94fe\u88681. \u7ed3\u6784\u4f531.1 \u9879\u76ee\u5f15\u5165-\u6210\u7ee9\u7cfb\u7edf\u7b2c\u4e8c\u6b21\u6539\u7248\u5148\u628a\u51fa\u4e8b\u90a3\u7248\u644a\u5f00\u3002\u4e09\u4e2a\u6570\u7ec4\u5e76\u6392&#xff0c;\u52a0\u4e2a\u73ed\u7ea7\u5b57\u6bb5\u4e4b\u540e\u957f\u8fd9\u6837\u3002#include #include using namespace std;int main() {string names[5] { \"\u5f20\u4e09\", \"\u674e\u56db\", \"\u738b\u4e94\", \"\u8d75\u516d\", \"\u5b59\u4e03\" };int scores[5] { 78, 92, 55, 100, 88 };int cla","og_url":"https:\/\/www.wsisp.com\/helps\/119688.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-10-29T22:16:32+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"9 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/119688.html","url":"https:\/\/www.wsisp.com\/helps\/119688.html","name":"\u7b2c\u4e5d\u7ae0 \u7ed3\u6784\u4f53\u3001\u679a\u4e3e\u7c7b\u578b\u548c\u94fe\u8868 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-10-29T22:16:32+00:00","dateModified":"2026-10-29T22:16:32+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/119688.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/119688.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/119688.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u7b2c\u4e5d\u7ae0 \u7ed3\u6784\u4f53\u3001\u679a\u4e3e\u7c7b\u578b\u548c\u94fe\u8868"}]},{"@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\/119688","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=119688"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/119688\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=119688"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=119688"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=119688"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=119688"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}