{"id":655,"date":"2016-01-17T19:49:36","date_gmt":"2016-01-17T11:49:36","guid":{"rendered":"http:\/\/yangwang.hk\/?p=655"},"modified":"2016-01-17T19:49:36","modified_gmt":"2016-01-17T11:49:36","slug":"3-12%e3%80%81switch","status":"publish","type":"post","link":"https:\/\/yangwang.hk\/?p=655","title":{"rendered":"3.12\u3001switch"},"content":{"rendered":"<p>\u524d\u9762\u6211\u4eec\u6240\u5b66\u7684if(-else)\u7ed3\u6784\u53ef\u4ee5\u7528\u4e8e\u6839\u636e\u4e0d\u540c\u7684\u6761\u4ef6\u6709\u9009\u62e9\u6027\u7684\u6267\u884c\u4e0d\u540c\u7684\u8bed\u53e5<\/p>\n<p>\u4f46\u662f\uff0c\u5982\u679c\u9047\u5230\u6709\u8f83\u591a\u5206\u652f\u7684\u8bed\u53e5\uff0c\u4ecd\u7528if-else\u6765\u5904\u7406\u65f6<\/p>\n<p>\u4f60\u5c31\u9700\u8981\u5199\u4e00\u5806\u7684if-else\u7ed3\u6784\uff0c\u8fd9\u6837\u5199\u663e\u7136\u5f88\u9ebb\u70e6<\/p>\n<p>\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u5c31\u8be5switch\u4e0a\u573a\u4e86<\/p>\n<p>\u6211\u4eec\u5148\u6765\u5199\u8fd9\u6837\u4e00\u4e2a\u7a0b\u5e8f\uff1a\u8ba9\u7528\u6237\u8f93\u5165\u4e00\u4e2a\u8303\u56f4\u57281-7\u7684\u6574\u6570\uff0c\u5e76\u4e14\u6839\u636e\u8fd9\u4e9b\u6570\u5b57\u8f93\u51fa\u5468\u4e00\u81f3\u5468\u4e03\uff0c1\u5bf9\u5e94\u5468\u4e00\uff0c2\u5bf9\u5e94\u5468\u4e8c\uff0c\u4f9d\u6b64\u7c7b\u63a8\u3002<\/p>\n<p>\u8bf7\u4f60\u9996\u5148\u5199\u51fa\u4e00\u4e2a\u4f7f\u7528if-else\u7684\u7248\u672c<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n#include &lt;stdio.h&gt;\r\n#include &lt;stdlib.h&gt;\r\n\r\nint main()\r\n{\r\n    int input;\r\n    printf(&quot;\u8bf7\u8f93\u5165\u4e00\u4e2a\u8303\u56f4\u57281~7\u7684\u6574\u6570\uff1a&quot;);\r\n    scanf(&quot;%d&quot;, &amp;input);\r\n\r\n    while(input &gt; 7 || input &lt; 1)\r\n    {\r\n        printf(&quot;\u8f93\u5165\u65e0\u6548\uff0c\u8bf7\u91cd\u65b0\u8f93\u5165\uff1a&quot;);\r\n        scanf(&quot;%d&quot;, &amp;input);\r\n    }\r\n\r\n    if(1 == input)\r\n    {\r\n        printf(&quot;\u661f\u671f\u4e00\\n&quot;);\r\n    }\r\n    else if(2 == input)\r\n    {\r\n        printf(&quot;\u661f\u671f\u4e8c\\n&quot;);\r\n    }\r\n    else if(3 == input)\r\n    {\r\n        printf(&quot;\u661f\u671f\u4e09\\n&quot;);\r\n    }\r\n    else if(4 == input)\r\n    {\r\n        printf(&quot;\u661f\u671f\u56db\\n&quot;);\r\n    }\r\n    else if(5 == input)\r\n    {\r\n        printf(&quot;\u661f\u671f\u4e94\\n&quot;);\r\n    }\r\n    else if(6 == input)\r\n    {\r\n        printf(&quot;\u661f\u671f\u516d\\n&quot;);\r\n    }\r\n    else\r\n    {\r\n        printf(&quot;\u661f\u671f\u5929\\n&quot;);\r\n    }\r\n\r\n    return 0;\r\n}\r\n<\/pre>\n<p>\u53ef\u4ee5\u770b\u51fa\u6765\uff0c\u8fd9\u6837\u5199\u771f\u7684\u5f88\u957f\u2026\u2026<\/p>\n<p>\u5f53\u7136\uff0c\u8fd9\u4e2a\u7a0b\u5e8f\u8fd8\u6709\u53e6\u4e00\u79cd\u5199\u6cd5<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n#include &lt;stdio.h&gt;\r\n#include &lt;stdlib.h&gt;\r\n\r\nint main()\r\n{\r\n    int input;\r\n    printf(&quot;\u8bf7\u8f93\u5165\u4e00\u4e2a\u8303\u56f4\u57281~7\u7684\u6574\u6570\uff1a&quot;);\r\n    scanf(&quot;%d&quot;, &amp;input);\r\n\r\n    while(input &gt; 7 || input &lt; 1)\r\n    {\r\n        printf(&quot;\u8f93\u5165\u65e0\u6548\uff0c\u8bf7\u91cd\u65b0\u8f93\u5165\uff1a&quot;);\r\n        scanf(&quot;%d&quot;, &amp;input);\r\n    }\r\n\r\n    if(1 == input)\r\n    {\r\n        printf(&quot;\u661f\u671f\u4e00\\n&quot;);\r\n    }\r\n    else\r\n    {\r\n        if(2 == input)\r\n        {\r\n            printf(&quot;\u661f\u671f\u4e8c\\n&quot;);\r\n        }\r\n        else\r\n        {\r\n            if(3 == input)\r\n            {\r\n                printf(&quot;\u661f\u671f\u4e09\\n&quot;);\r\n            }\r\n            else\r\n            {\r\n                if(4 == input)\r\n                {\r\n                    printf(&quot;\u661f\u671f\u56db\\n&quot;);\r\n                }\r\n                else\r\n                {\r\n                    if(5 == input)\r\n                    {\r\n                        printf(&quot;\u661f\u671f\u4e94\\n&quot;);\r\n                    }\r\n                    else\r\n                    {\r\n                        if(6 == input)\r\n                        {\r\n                            printf(&quot;\u661f\u671f\u516d\\n&quot;);\r\n                        }\r\n                        else\r\n                        {\r\n                            printf(&quot;\u661f\u671f\u5929\\n&quot;);\r\n                        }\r\n                    }\r\n                }\r\n            }\r\n        }\r\n    }\r\n\r\n    return 0;\r\n}\r\n<\/pre>\n<p>\u8fd9\u4e24\u79cd\u7684\u5199\u6cd5\u672c\u8d28\u662f\u76f8\u540c\u7684<\/p>\n<p>\u800c\u4e14\u6b63\u5e38\u4eba\u90fd\u770b\u5f97\u51fa\u6765\uff0c\u4f7f\u7528if-else\u6765\u8fdb\u884c\u8df3\u8f6c\uff0c\u5199\u8d77\u6765\u5b9e\u5728\u662f\u9ebb\u70e6<\/p>\n<p>\u90a3\u4e48switch\u53c8\u600e\u4e48\u7528\u5462\uff1f<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\nswitch(\u8868\u8fbe\u5f0f)\r\n{\r\n    case \u5e38\u91cf\u8868\u8fbe\u5f0f1: \/\/\u4e00\u4e9b\u4ee3\u7801\r\n    case \u5e38\u91cf\u8868\u8fbe\u5f0f2: \/\/\u53e6\u4e00\u4e9b\u4ee3\u7801\r\n    default :\/\/\u5904\u7406\u610f\u5916\u60c5\u51b5\u7684\u4ee3\u7801\r\n}\r\n<\/pre>\n<p>\u6ce8\u610f\uff0c\u4e00\u4e2a\u8868\u8fbe\u5f0f\u4e0d\u4e00\u5b9a\u8981\u662f\u4e00\u4e2a\u5f0f\u5b50\uff0c\u5bf9\u4e8e\u4e00\u4e2a\u6570\u5b57\uff08\u59821\uff09\u6216\u8005\u5355\u72ec\u7684\u4e00\u4e2a\u53d8\u91cffoo\uff0c\u5b83\u4eec\u90fd\u662f\u8868\u8fbe\u5f0f<\/p>\n<p>switch\u540e\u7684\u8868\u8fbe\u5f0f\u7684\u503c\u4fbf\u662f\u4f60\u8981\u5224\u65ad\u7684\u503c\uff0c\u4f8b\u5982\u4e0a\u9762\u7684\u7a0b\u5e8f\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u5199\u6210<\/p>\n<p><code>switch(input)<\/code><\/p>\n<p>switch\u5bf9\u4e8e\u62ec\u53f7\u5185\u7684\u8868\u8fbe\u5f0f\u6709\u8981\u6c42\uff0c\u5b83\u8981\u6c42\u8868\u8fbe\u5f0f\u7684\u503c\u662f\u4e00\u4e2a\u6574\u578b\uff08\u6216\u8005\u5176\u4ed6\u80fd\u88ab\u8f6c\u6362\u4e3a\u6574\u578b\u7684\u7c7b\u578b\uff09<\/p>\n<p>\u5bf9\u4e8e\u6d6e\u70b9\u6570\uff0c\u662f\u4e0d\u80fd\u591f\u4f7f\u7528switch\u7684\uff01<\/p>\n<p>\u8fd9\u91cc\u7684\u6bcf\u4e00\u4e2acase\u90fd\u662f\u4e00\u4e2a\u5206\u652f\uff08case\u5728\u82f1\u8bed\u4e2d\u7684\u610f\u601d\u6709\u201c\u60c5\u51b5\u201d\uff09\uff0c\u5176\u540e\u9762\u8ddf\u968f\u7684\u5e38\u91cf\u8868\u8fbe\u5f0f\u7684\u503c\u4fbf\u662f\u5176\u5bf9\u5e94\u7684\u503c\uff08\u6211\u4eec\u79f0\u5176\u4e3a\u6807\u53f7\uff0clabel\uff09<\/p>\n<p>\u8fd9\u91cc\u8981\u6c42\u503c\u662f\u4e00\u4e2a\u5e38\u91cf\uff0c\u4f8b\u59821,2,3\uff0c\u5f53\u7136&#8217;a&#8217;\u7b49\u5b57\u7b26\u4e5f\u662f\u53ef\u4ee5\u7684\uff0c\u56e0\u4e3a\u5b83\u7684\u5b9e\u8d28\u4e5f\u662f\u6570<\/p>\n<p>\u4f46\u662f\u4f60\u4e0d\u80fd\u4f7f\u7528\u53d8\u91cf\uff0c\u751a\u81f3\u662fconst\u4fee\u9970\u7684\u201c\u5e38\u91cf\u201d\uff08\u5982const int\uff09\uff0c\u7c7b\u4f3c\u4e8ecase foo\u7684\u5199\u6cd5\u662f\u4e0d\u5408\u6cd5\u7684<\/p>\n<p>\u9664case\u5916\uff0c\u8fd8\u6709\u4e00\u4e2adefault\uff0c\u5f53switch\u91cc\u7684\u503c\u6ca1\u6709\u5339\u914d\u4e0e\u4efb\u4f55\u4e00\u4e2acase\u65f6\uff0c\u5c06\u8df3\u8f6c\u5230default\u3002<\/p>\n<p>\u4e00\u4e2aswitch\u4e2d\u53ea\u5141\u8bb8\u6709\u4e00\u4e2adefault<\/p>\n<p>\u8bf4\u4e86\u8fd9\u4e48\u591a\uff0c\u6211\u4eec\u4e0d\u5982\u770b\u4e00\u4e0b\u4ee3\u7801<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n#include &lt;stdio.h&gt;\r\n#include &lt;stdlib.h&gt;\r\n\r\nint main()\r\n{\r\n    int input;\r\n    printf(&quot;\u8bf7\u8f93\u5165\u4e00\u4e2a\u8303\u56f4\u57281~7\u7684\u6574\u6570\uff1a&quot;);\r\n    scanf(&quot;%d&quot;, &amp;input);\r\n\r\n    while(input &gt; 7 || input &lt; 1)\r\n    {\r\n        printf(&quot;\u8f93\u5165\u65e0\u6548\uff0c\u8bf7\u91cd\u65b0\u8f93\u5165\uff1a&quot;);\r\n        scanf(&quot;%d&quot;, &amp;input);\r\n    }\r\n\r\n    switch(input)\r\n    {\r\n    case 1:\r\n        {\r\n            printf(&quot;\u661f\u671f\u4e00\\\\n&quot;);\r\n            break;\r\n        }\r\n    case 2:\r\n        {\r\n            printf(&quot;\u661f\u671f\u4e8c\\n&quot;);\r\n            break;\r\n        }\r\n    case 3:\r\n        {\r\n            printf(&quot;\u661f\u671f\u4e09\\n&quot;);\r\n            break;\r\n        }\r\n    case 4:\r\n        {\r\n            printf(&quot;\u661f\u671f\u56db\\n&quot;);\r\n            break;\r\n        }\r\n    case 5:\r\n        {\r\n            printf(&quot;\u661f\u671f\u4e94\\n&quot;);\r\n            break;\r\n        }\r\n    case 6:\r\n        {\r\n            printf(&quot;\u661f\u671f\u516d\\n&quot;);\r\n            break;\r\n        }\r\n    case 7:\r\n        {\r\n            printf(&quot;\u661f\u671f\u5929\\n&quot;);\r\n            break;\r\n        }\r\n        default:break;\r\n    }\r\n    return 0;\r\n}\r\n\r\n<\/pre>\n<p>\u662f\u4e0d\u662f\u987f\u65f6\u89c9\u5f97\u6e05\u6670\u5f88\u591a\u5462\uff1f<\/p>\n<p>\u548cif\u7b49\u7ed3\u6784\u4e0d\u540c\uff0cswitch\u4e2dcase\u540e\u9762\u7684\u5927\u62ec\u53f7\u4e0d\u662f\u5fc5\u987b\u7684\uff08\u4e0d\u7ba1\u5b83\u540e\u9762\u6709\u591a\u5c11\u4e2a\u8bed\u53e5\uff09<\/p>\n<p>\u8fd9\u662f\u56e0\u4e3a\u4f60\u53ef\u4ee5\u901a\u8fc7\u4e0b\u4e00\u4e2acase\u6807\u7b7e\u5f88\u597d\u7684\u533a\u5206\u67d0\u4e00\u4e2a\u8bed\u53e5\u5c5e\u4e8e\u54ea\u4e00\u4e2acase\uff08\u5373\u4e0d\u4f1a\u5f15\u8d77\u6b67\u4e49\uff0c\u8bf7\u601d\u8003if\u4e3a\u4f55\u4f1a\u6709\u6b67\u4e49\uff09<\/p>\n<p>\u63a5\u4e0b\u6765\u8bf7\u770bcase\u5185\u7684\u4ee3\u7801\uff0c\u6211\u4eec\u5728\u6bcf\u4e00\u4e2a\u5206\u652f\u91cc\u90fd\u6dfb\u52a0\u4e86\u4e00\u4e2abreak\uff0c\u8fd9\u662f\u591a\u4f59\u7684\u5417\uff1f<\/p>\n<p>\u663e\u7136\u4e0d\u662f\uff0c\u8fd9\u548cswitch\u7684\u6267\u884c\u8fc7\u7a0b\u6709\u5173<\/p>\n<p>\u5047\u8bbe\u4e0a\u9762\u7684\u7a0b\u5e8f\u91cc\u6211\u4eec\u8f93\u5165\u4e86\u6570\u5b572\uff1b<\/p>\n<p>\u90a3\u4e48switch\u4f1a\u6839\u636einput\uff08\u53732\uff09\u7684\u503c\u8df3\u8f6c\u5230case 2\u8fd9\u4e2a\u5206\u652f\uff0c\u7136\u540e\u6267\u884c\u5185\u90e8\u7684\u4ee3\u7801\uff08\u8fd9\u91cc\u662fprintf\uff09<\/p>\n<p>\u4f46\u662f\u5728\u6267\u884c\u5b8c\u6bd5\u540e\uff0cswitch\u5e76\u4e0d\u4f1a\u8df3\u51fa\u6765\u6267\u884cswitch\u7ed3\u6784\u540e\u9762\u7684\u4ee3\u7801\uff0c\u800c\u662f\u987a\u7740\u6807\u53f72\u6240\u5728\u7684\u5206\u652f\u5f80\u4e0b\u6267\u884c\uff08\u5373case 3\u5185\u7684\u4ee3\u7801\uff09<\/p>\n<p>\u5018\u82e5\u4e0b\u9762\u7684\u5206\u652f\u90fd\u6ca1\u6709\u6dfb\u52a0break\uff0c\u90a3\u4e48\u7a0b\u5e8f\u5c06\u4f1a\u4e00\u76f4\u6267\u884c\u5230\u6807\u53f7\u4e3a7\u7684\u5206\u652f\uff0c\u63a5\u7740\u662fdefault\u5185\u7684\u4ee3\u7801\uff0c\u76f4\u5230switch\u7ed3\u675f\u624d\u4f1a\u8df3\u51fa<\/p>\n<p>\u800c\u52a0\u4e86break\u4e4b\u540e\u5219\u4f1a\u76f4\u63a5\u8df3\u51faswitch\uff0c\u8fd9\u624d\u662f\u6211\u4eec\uff08\u5728\u8fd9\u4e2a\u7a0b\u5e8f\u4e2d\uff09\u9700\u8981\u7684\u7ed3\u679c<\/p>\n<p>\u8bf7\u4f60\u5220\u9664break\uff0c\u518d\u8fdb\u884c\u5c1d\u8bd5<\/p>\n<p>\u6ce8\u610f\uff0c\u6ca1\u6709break\u65f6\u6267\u884c\u7684\u987a\u5e8f\u548c\u6807\u53f7\u5927\u5c0f\u65e0\u5173\uff0c\u548ccase\u548cdefault\u4e5f\u65e0\u5173\uff0c\u800c\u4e4b\u548c\u4f60\u7a0b\u5e8f\u7684\u4e66\u5199\u987a\u5e8f\u6709\u5173<\/p>\n<p>\u4f60\u53ef\u4ee5\u4efb\u610f\u7684\u4ea4\u6362case\uff08\u8fd8\u6709default\uff09\u7684\u987a\u5e8f\uff0c\u4f46\u662f\u901a\u5e38\u6211\u4eec\u90fd\u6309\u7167\u4e00\u5b9a\u7684\u987a\u5e8f\u5199\uff0c\u800c\u4e14\u5c06default\u653e\u5728\u6700\u540e<\/p>\n<p><strong>default\u4e0d\u662f\u5fc5\u987b\u7684\uff0c<\/strong>\u5bf9\u4e8e\u6ca1\u6709default\u7684switch\uff0c\u5728\u6ca1\u6709\u5339\u914d\u5230\u4efb\u4f55\u4e00\u4e2acase\u65f6\u4f1a\u76f4\u63a5\u8df3\u5230switch\u540e\u9762\u7684\u4ee3\u7801\u6267\u884c<\/p>\n<p>default\u901a\u5e38\u662f\u7528\u4e8e\u5904\u7406\u201c\u975e\u6b63\u5e38\u201d\u60c5\u51b5\u7684\uff0c\u5728\u6b64\u7a0b\u5e8f\u4e2d\u4fbf\u662f\u503c\u4e0d\u57281-7\u8303\u56f4\u5185\u7684\u60c5\u51b5<\/p>\n<p>\u56e0\u6b64\uff0c\u5728\u8fd9\u4e2a\u7a0b\u5e8f\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u5220\u9664default\uff08\u56e0\u4e3a\u5728\u8f93\u5165\u7684\u5730\u65b9\u6211\u4eec\u4fbf\u5224\u65ad\u4e86\u8f93\u5165\u503c\u7684\u5927\u5c0f\uff09<\/p>\n<p>\u4f46\u662f\uff0c\u51fa\u4e8e\u597d\u4e60\u60ef\uff0c\u4f60\u5e94\u8be5\u5728\u4efb\u4f55\u4e00\u4e2aswitch\u4e2d\u90fd\u5199\u4e0adefault\uff0c<strong>\u54ea\u6015\u4f60\u786e\u5b9a\u4e00\u5b9a\u4ee5\u53ca\u80af\u5b9a\u5b83\u4e0d\u4f1a\u88ab\u6267\u884c<\/strong>\uff08\u4f8b\u5982\u8fd9\u4e2a\u7a0b\u5e8f\uff09<\/p>\n<p>\u54ea\u6015\u5b83\u786e\u5b9e\u65e0\u4e8b\u53ef\u5e72\uff01\u56e0\u4e3a\u8fd9\u6837\u4fbf\u8bf4\u660e\u4f60\u5df2\u7ecf\u8003\u8651\u8fc7\u4e86\u5176\u5b83\u7684\u60c5\u51b5<\/p>\n<p>\u6700\u540e\uff0c\u4f60\u53ef\u80fd\u4f1a\u95ee\uff0c\u5bf9\u4e8e\u6570\u503c\u4e0d\u662f\u6574\u6570\uff08\u5982\u6d6e\u70b9\u6570\uff09\u65f6\uff0c\u53c8\u6216\u8005\u5224\u65ad\u7684\u662f\u4e00\u4e2a\u6570\u662f\u5426\u5728\u4e00\u4e2a\u8303\u56f4\u5185\u53c8\u5e94\u8be5\u5982\u4f55\u5904\u7406\u5462\uff1f<\/p>\n<p>\u6ca1\u6709\u529e\u6cd5\uff0c\u5bf9\u4e8e\u590d\u6742\u7684\u5224\u65ad\uff0c\u8df3\u8f6c\uff0c\u4f60\u53ea\u80fd\u4f7f\u7528if-else\uff01<\/p>\n<p>\u6700\u540e\uff0c\u8bf7\u4f60\u505a\u4ee5\u4e0b\u7ec3\u4e60<\/p>\n<ul>\n<li>\u5220\u9664\u5224\u65adinput\u503c\u7684\u5faa\u73af\u4ee3\u7801\uff0c\u5e76\u5728default\u5185\u7ed9\u51fa\u63d0\u793a\uff08\u5982\u679c\u6570\u4e0d\u57281-7\u7684\u60c5\u51b5\u4e0b\uff09<\/li>\n<li>\u5220\u9664switch\u5206\u652f\u5185\u7684break\uff0c\u89c2\u5bdfswitch\u7684\u6267\u884c<\/li>\n<li>\u5728\u4e0a\u4e00\u4e2a\u5b9e\u9a8c\u7684\u524d\u63d0\u4e0b\uff0c\u8c03\u6574\u51e0\u4e2acase\u7684\u987a\u5e8f\uff0c\u5e76\u89c2\u5bdf\u7a0b\u5e8f\u7684\u6267\u884c<\/li>\n<\/ul>\n<hr \/>\n<p>ps\uff1a\u56e0\u4e3acase\u6267\u884c\u4e86\u4e0d\u4f1a\u81ea\u52a8\u8df3\u51fa\u8fd9\u4e2a\u7279\u6027\uff0c\u6211\u4eec\u53ef\u4ee5\u5199\u51fa\u4e0b\u9762\u7684\u4ee3\u7801<\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n#include &lt;stdio.h&gt;\r\n#include &lt;stdlib.h&gt;\r\n\r\nint main()\r\n{\r\n    int input;\r\n    printf(&quot;\u8bf7\u8f93\u5165\u4e00\u4e2a\u8303\u56f4\u57281~7\u7684\u6574\u6570\uff1a&quot;);\r\n    scanf(&quot;%d&quot;, &amp;input);\r\n\r\n    while(input &gt; 7 || input &lt; 1)\r\n    {\r\n        printf(&quot;\u8f93\u5165\u65e0\u6548\uff0c\u8bf7\u91cd\u65b0\u8f93\u5165\uff1a&quot;);\r\n        scanf(&quot;%d&quot;, &amp;input);\r\n    }\r\n\r\n    switch(input)\r\n    {\r\n    case 1:\r\n    case 2:\r\n    case 3:\r\n    case 4:\r\n    case 5:\r\n        printf(&quot;\u5de5\u4f5c\u65e5\\n&quot;);\r\n        break;\r\n    case 6:\r\n    case 7:\r\n        printf(&quot;\u4f11\u606f\u65e5\\n&quot;);\r\n        break;\r\n\r\n    default:break;\r\n\r\n    }\r\n    return 0;\r\n}\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u9762\u6211\u4eec\u6240\u5b66\u7684if(-else)\u7ed3\u6784\u53ef\u4ee5\u7528\u4e8e\u6839\u636e\u4e0d\u540c\u7684\u6761\u4ef6\u6709\u9009\u62e9\u6027\u7684\u6267\u884c\u4e0d\u540c\u7684\u8bed\u53e5 \u4f46\u662f\uff0c\u5982\u679c\u9047\u5230\u6709\u8f83\u591a\u5206\u652f\u7684\u2026 <span class=\"read-more\"><a href=\"https:\/\/yangwang.hk\/?p=655\">Read More: 3.12\u3001switc\u2026 &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-655","post","type-post","status-publish","format-standard","hentry","category-c"],"views":3129,"_links":{"self":[{"href":"https:\/\/yangwang.hk\/index.php?rest_route=\/wp\/v2\/posts\/655","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yangwang.hk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yangwang.hk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yangwang.hk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yangwang.hk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=655"}],"version-history":[{"count":1,"href":"https:\/\/yangwang.hk\/index.php?rest_route=\/wp\/v2\/posts\/655\/revisions"}],"predecessor-version":[{"id":656,"href":"https:\/\/yangwang.hk\/index.php?rest_route=\/wp\/v2\/posts\/655\/revisions\/656"}],"wp:attachment":[{"href":"https:\/\/yangwang.hk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=655"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yangwang.hk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=655"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yangwang.hk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=655"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}