{"id":13631,"date":"2025-04-18T20:32:50","date_gmt":"2025-04-18T12:32:50","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/13631.html"},"modified":"2025-04-18T20:32:50","modified_gmt":"2025-04-18T12:32:50","slug":"%e9%80%89%e6%8b%a9%e7%bb%93%e6%9e%84%e7%a8%8b%e5%ba%8f%e8%ae%be%e8%ae%a1%ef%bc%881-3%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/13631.html","title":{"rendered":"\u9009\u62e9\u7ed3\u6784\u7a0b\u5e8f\u8bbe\u8ba1\uff081\/3\uff09"},"content":{"rendered":"<p id=\"main-toc\">\u76ee\u5f55<\/p>\n<p id=\"if%E8%AF%AD%E5%8F%A5(%E5%88%86%E6%94%AF%E8%AF%AD%E5%8F%A5)-toc\" style=\"margin-left:0px\">if\u8bed\u53e5(\u5206\u652f\u8bed\u53e5)<\/p>\n<p id=\"if%E8%AF%AD%E5%8F%A5%E7%9A%84%E5%9F%BA%E6%9C%AC%E5%BD%A2%E5%BC%8F-toc\" style=\"margin-left:80px\">if\u8bed\u53e5\u7684\u57fa\u672c\u5f62\u5f0f<\/p>\n<p id=\"if...else%E8%AF%AD%E5%8F%A5%E5%BD%A2%E5%BC%8F-toc\" style=\"margin-left:80px\">if&#8230;else\u8bed\u53e5\u5f62\u5f0f<\/p>\n<p id=\"1.%E5%9F%BA%E6%9C%AC%E5%BD%A2%E5%BC%8F%EF%BC%9A-toc\" style=\"margin-left:200px\">1.\u57fa\u672c\u5f62\u5f0f&#xff1a;<\/p>\n<p id=\"2.if...else%E6%89%A7%E8%A1%8C%E6%B5%81%E7%A8%8B%E5%9B%BE%E5%A6%82%E5%9B%BE-toc\" style=\"margin-left:200px\">2.if&#8230;else\u6267\u884c\u6d41\u7a0b\u56fe\u5982\u56fe<\/p>\n<p id=\"3.%E5%AD%98%E5%9C%A8%E5%A4%9A%E4%B8%AAif%E5%92%8Celse%E9%97%AE%E9%A2%98-toc\" style=\"margin-left:200px\">3.\u5b58\u5728\u591a\u4e2aif\u548celse\u95ee\u9898<\/p>\n<p id=\"else%20if%E8%AF%AD%E5%8F%A5%E5%BD%A2%E5%BC%8F-toc\" style=\"margin-left:80px\">else if\u8bed\u53e5\u5f62\u5f0f<\/p>\n<p id=\"1.%E5%9F%BA%E6%9C%AC%E5%BD%A2%E5%BC%8F-toc\" style=\"margin-left:200px\">1.\u57fa\u672c\u5f62\u5f0f<\/p>\n<p id=\"2.%E5%9F%BA%E6%9C%AC%E6%B5%81%E7%A8%8B%E5%9B%BE-toc\" style=\"margin-left:200px\">2.\u57fa\u672c\u6d41\u7a0b\u56fe<\/p>\n<p id=\"%C2%A03.%E6%A0%B9%E6%8D%AE%E6%97%B6%E9%97%B4%E8%BE%93%E5%87%BA%E9%97%AE%E5%80%99%E8%AF%AD-toc\" style=\"margin-left:200px\">\u00a03.\u6839\u636e\u65f6\u95f4\u8f93\u51fa\u95ee\u5019\u8bed<\/p>\n<p id=\"4.%E8%AE%A1%E7%AE%97%E5%88%86%E6%AE%B5%E5%87%BD%E6%95%B0-toc\" style=\"margin-left:200px\">4.\u8ba1\u7b97\u5206\u6bb5\u51fd\u6570<\/p>\n<p id=\"if%E7%9A%84%E5%B5%8C%E5%A5%97%E5%BD%A2%E5%BC%8F-toc\" style=\"margin-left:80px\">if\u7684\u5d4c\u5957\u5f62\u5f0f<\/p>\n<p id=\"1.%E5%9F%BA%E6%9C%AC%E5%BD%A2%E5%BC%8F-toc\" style=\"margin-left:200px\">1.\u57fa\u672c\u5f62\u5f0f<\/p>\n<p id=\"2.if%E5%B5%8C%E5%A5%97%E5%BA%94%E7%94%A8-toc\" style=\"margin-left:200px\">2.if\u5d4c\u5957\u5e94\u7528<\/p>\n<hr id=\"hr-toc\" \/>\n<\/p>\n<p><span style=\"color:#511b78\">\u9009\u62e9\u6027\u7ed3\u6784\u8bbe\u8ba1\u9700\u8981\u7528\u5230\u4e00\u4e9b\u4e9b\u6761\u4ef6\u5224\u65ad\u8bed\u53e5&#xff0c;\u53ef\u5b9e\u73b0\u7a0b\u5e8f\u529f\u80fd\u66f4\u52a0\u590d\u6742&#xff0c;\u7a0b\u5e8f\u7684\u903b\u8f91\u6027\u548c\u9009\u62e9\u6027\u95ee\u9898\u4e5f\u66f4\u52a0\u5f3a\u5927\u3002<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"611\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418123249-680246711357e.png\" width=\"837\" \/><\/p>\n<h2 id=\"if%E8%AF%AD%E5%8F%A5(%E5%88%86%E6%94%AF%E8%AF%AD%E5%8F%A5)\">if\u8bed\u53e5(\u5206\u652f\u8bed\u53e5)<\/h2>\n<h4 id=\"if%E8%AF%AD%E5%8F%A5%E7%9A%84%E5%9F%BA%E6%9C%AC%E5%BD%A2%E5%BC%8F\">if\u8bed\u53e5\u7684\u57fa\u672c\u5f62\u5f0f<\/h4>\n<p>if\u8bed\u53e5\u7684\u4e00\u822c\u5f62\u5f0f\u5982\u4e0b&#xff1a;<\/p>\n<p>if&#xff08;\u8868\u8fbe\u5f0f&#xff09;\u8bed\u53e5 <\/p>\n<p>\u62ec\u53f7\u5185\u7684\u8868\u8fbe\u5f0f\u5c31\u662f\u8981\u8fdb\u884c\u5224\u65ad\u7684\u6761\u4ef6&#xff0c;\u8bed\u53e5\u5219\u662f\u6267\u884c\u7684\u5bf9\u5e94\u64cd\u4f5c\u3002\u62ec\u53f7\u5185\u7684\u8868\u8fbe\u5f0f\u4e3a\u771f&#xff0c;\u5c31\u6267\u884c\u540e\u9762\u7684\u8bed\u53e5&#xff1b;\u62ec\u53f7\u5185\u7684\u8868\u8fbe\u5f0f\u4e3a\u5047&#xff0c;\u5219\u4e0d\u4f1a\u6267\u884c\u540e\u9762\u7684\u8bed\u53e5\u3002\u4f8b\u5982\u4e0b\u9762\u7684\u4ee3\u7801&#xff1a;<\/p>\n<p>if&#xff08;iNum&#xff09;printf&#xff08;\u201cThe turevalue\u201d&#xff09;; <\/p>\n<p>\u4e0a\u8ff0\u4ee3\u7801\u4e2d&#xff0c;\u5982\u679ciNum\u7684\u503c\u4e3a\u771f&#xff0c;\u5219\u6267\u884c\u540e\u9762printf\u8bed\u53e5&#xff1b;\u53cd\u4e4b&#xff0c;\u5219\u4e0d\u6267\u884c\u00a0\u3002<\/p>\n<p>if&#xff08;age&gt;18&#xff09;printf(&#034;\u6210\u5e74&#034;);<\/p>\n<p>\u4e0a\u8ff0\u4ee3\u7801\u4e2d&#xff0c;\u9996\u5148\u5224\u65ad\u8868\u8fbe\u5f0f\u201cage&gt;18\u201d\u662f\u5426\u6210\u7acb&#xff0c;\u5982\u679c\u6761\u4ef6\u6210\u7acb&#xff0c;\u90a3\u4e48\u5224\u65ad\u7ed3\u679c\u662f\u771f&#xff0c;\u6267\u884c\u540e\u9762\u8f93\u51fa\u8bed\u53e5;\u53cd\u4e4b&#xff0c;\u4e0d\u6267\u884c\u3002<\/p>\n<p>\u524d\u9762\u4e24\u6bb5\u4ee3\u7801&#xff0c;if\u540e\u6267\u884c\u7684\u8bed\u53e5\u53ea\u6709\u4e00\u6761&#xff0c;\u5982\u679c\u6709\u4e24\u6761\u8bed\u53e5\u6216\u591a\u6761\u8bed\u53e5&#xff0c;\u53ef\u4ee5\u4f7f\u7528\u5927\u62ec\u53f7&#xff0c;\u4f7f\u4e4b\u6210\u4e3a\u8bed\u53e5\u5757<\/p>\n<p>if (age &gt; 18)<br \/>\n{<br \/>\nprintf(&#034;\u6210\u5e74\\\\n&#034;);<br \/>\nprintf(&#034;\u81ea\u529b\u66f4\u751f\\\\n&#034;);<br \/>\n} <\/p>\n<p><span style=\"color:#511b78\">\u8bef\u533a&#xff1a;if\u8bed\u53e5\u7684\u62ec\u53f7\u540e\u4e00\u5b9a\u4e0d\u8981\u6dfb\u52a0\u82f1\u6587\u5206\u53f7&#xff08;;&#xff09;\u3002\u00a0<\/span><\/p>\n<p>\u00a0if\u8bed\u53e5\u7684\u6267\u884c\u6d41\u7a0b\u56fe\u5982\u4e0b\u6240\u793a<\/p>\n<p style=\"text-align:right\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"201\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418123249-68024671457e5.png\" width=\"200\" \/><\/p>\n<p style=\"text-align:right\">\n<h4 id=\"if...else%E8%AF%AD%E5%8F%A5%E5%BD%A2%E5%BC%8F\">if&#8230;else\u8bed\u53e5\u5f62\u5f0f<\/h4>\n<h6 id=\"1.%E5%9F%BA%E6%9C%AC%E5%BD%A2%E5%BC%8F%EF%BC%9A\">1.\u57fa\u672c\u5f62\u5f0f&#xff1a;<\/h6>\n<p>if (\u8868\u8fbe\u5f0f)<br \/>\n{<br \/>\n\u8bed\u53e5\u57571;<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\n\u8bed\u53e5\u57572;<br \/>\n} <\/p>\n<h6 id=\"2.if...else%E6%89%A7%E8%A1%8C%E6%B5%81%E7%A8%8B%E5%9B%BE%E5%A6%82%E5%9B%BE\">2.if&#8230;else\u6267\u884c\u6d41\u7a0b\u56fe\u5982\u56fe<\/h6>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" class=\"right\" height=\"252\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418123249-6802467162de6.png\" width=\"259\" \/><span style=\"color:#511b78\">\u00a0\u6ce8\u610f&#xff1a;\u6ce8\u610fif \u4e0eelse\u7684\u914d\u5bf9\u60c5\u51b5\u3002else\u603b\u662f\u4e0e\u5176\u524d\u9762\u672a\u914d\u5bf9\u7684if\u8fdb\u884c\u914d\u5bf9<\/span><\/p>\n<p>\u00a0\u5728if\u540e\u7684\u62ec\u53f7\u4e2d\u5224\u65ad\u8868\u8fbe\u5f0f\u7684\u7ed3\u679c&#xff0c;\u5982\u679c\u5224\u65ad\u7684\u7ed3\u679c\u4e3a\u771f\u503c&#xff0c;\u5219\u6267\u884cif\u540e\u9762\u8bed\u53e5\u5757\u7684\u5185\u5bb9&#xff1b;\u5982\u679c\u5224\u65ad\u7684\u7ed3\u679c\u4e3a\u5047\u503c&#xff0c;\u5219\u6267\u884celse\u540e\u8bed\u53e5\u5757\u7684\u5185\u5bb9<\/p>\n<p>if&#xff08;value&#xff09;<br \/>\n{<br \/>\n     printf(&#034;the value is ture&#034;);<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\n     printf(&#034;the value is false&#034;);<\/p>\n<p>\u4e0b\u9762\u6211\u4eec\u6765\u5236\u4f5c\u4e00\u6bb5\u7a0b\u5e8f\u6765\u5224\u65ad\u6761\u4ef6\u771f\u5047<\/p>\n<p>#include&lt;stdio.h&gt;<br \/>\nint main()<br \/>\n{<br \/>\nint iNum;<br \/>\nprintf(&#034;Enter a number\\\\n&#034;);<br \/>\nscanf(&#034;%d&#034;, &amp;iNum);<br \/>\nif (iNum)<br \/>\n{<br \/>\nprintf(&#034;the value is ture and the number is:%d\\\\n&#034;, iNum);<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nprintf(&#034;the value is flase and the number is:%d\\\\n&#034;, iNum);<br \/>\n}<br \/>\nreturn 0;<br \/>\n} <\/p>\n<p>\u00a0\u4f7f\u7528if&#8230;else\u8bed\u53e5\u5224\u65ad\u7528\u6237\u8f93\u5165\u7684\u6570\u503c\u3002\u8f93\u5165\u6570\u5b57\u4e3a0&#xff0c;\u8868\u793a\u6761\u4ef6\u4e3a\u5047&#xff1b;\u8f93\u5165\u6570\u5b57\u4e3a1&#xff0c;\u8868\u793a\u6761\u4ef6\u4e3a\u771f\u3002<\/p>\n<h6 id=\"3.%E5%AD%98%E5%9C%A8%E5%A4%9A%E4%B8%AAif%E5%92%8Celse%E9%97%AE%E9%A2%98\">3.\u5b58\u5728\u591a\u4e2aif\u548celse\u95ee\u9898<\/h6>\n<p>\u89c4\u5219&#xff1a;\u5982\u679c\u6709\u591a\u4e2aif\u548celse&#xff0c;else\u603b\u662f\u8ddf\u6700\u63a5\u8fd1\u7684if\u8fde\u63a5<\/p>\n<p>\/\/\u6839\u636e\u65f6\u95f4\u8f93\u51fa\u95ee\u5019\u8bed<br \/>\n#include&lt;stdio.h&gt;<br \/>\nint main()<br \/>\n{<br \/>\nint time;<br \/>\nprintf(&#034;\u8bf7\u8f93\u5165\u6b64\u65f6\u7684\u65f6\u95f4&#xff1a;&#034;);<br \/>\nscanf(&#034;%d&#034;, &amp;time);<br \/>\nif (time &lt; 12)<br \/>\nprintf(&#034;\u65e9\u4e0a\u597d\\\\n&#034;);<br \/>\nif (time &#061;&#061; 12)<br \/>\nprintf(&#034;\u4e2d\u5348\u597d\\\\n&#034;);<br \/>\nelse<br \/>\nprintf(&#034;\u665a\u4e0a\u597d\\\\n&#034;);<br \/>\nreturn 0;<br \/>\n} <\/p>\n<p>\u00a0\u4e0a\u9762\u8fd9\u4e2a\u7a0b\u5e8f\u5b9e\u9645\u4e0a\u662f\u5b58\u5728\u4e00\u4e9b\u95ee\u9898\u7684&#xff0c;\u5047\u5982\u7528\u6237\u8f93\u5165\u7684\u6570\u503c\u4e3a\u5c0f\u4e8e12\u7684\u6574\u6570&#xff0c;\u7b2c\u4e00\u4e2a\u8bed\u53e5\u5224\u65ad\u4e3a\u771f\u503c&#xff0c;\u5219\u4f1a\u6267\u884c\u540e\u9762\u7684\u8bed\u53e5\u5757\u3002\u7b2c\u4e8c\u4e2aif\u8bed\u53e5\u5224\u65ad\u51fatime\u503c\u4e0d\u7b49\u4e8e12&#xff0c;\u4e3a\u5047\u503c&#xff0c;\u4f1a\u6267\u884celse\u540e\u7684\u8bed\u53e5\u5757\u3002<\/p>\n<p>\u89e3\u51b3\u529e\u6cd5\u6211\u4f1a\u5728else if\u8bed\u53e5\u4e2d\u63d0\u5230<\/p>\n<h4 id=\"else%20if%E8%AF%AD%E5%8F%A5%E5%BD%A2%E5%BC%8F\">else if\u8bed\u53e5\u5f62\u5f0f<\/h4>\n<h6 id=\"1.%E5%9F%BA%E6%9C%AC%E5%BD%A2%E5%BC%8F\">1.\u57fa\u672c\u5f62\u5f0f<\/h6>\n<p>if (\u8868\u8fbe\u5f0f1)<br \/>\n{<br \/>\n\u8bed\u53e5\u57571<br \/>\n}<br \/>\nelse if (\u8868\u8fbe\u5f0f2)<br \/>\n{<br \/>\n\u8bed\u53e5\u57572<br \/>\n}<br \/>\nelse if (\u8868\u8fbe\u5f0f3)<br \/>\n{<br \/>\n\u8bed\u53e5\u57573<br \/>\n}<br \/>\n&#8230;<br \/>\nelse if (\u8868\u8fbe\u5f0fm)<br \/>\n{<br \/>\n\u8bed\u53e5\u5757m<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\n\u8bed\u53e5\u5757n<br \/>\n} <\/p>\n<h6 id=\"2.%E5%9F%BA%E6%9C%AC%E6%B5%81%E7%A8%8B%E5%9B%BE\">2.\u57fa\u672c\u6d41\u7a0b\u56fe<\/h6>\n<p><span style=\"color:#511b78\">\u00a0\u4f7f\u7528\u591a\u4e2aelse if \u8bed\u53e5\u65f6&#xff0c;\u8981\u683c\u5916\u6ce8\u610f\u4e0b\u65b9\u7684\u8bed\u53e5\u5757\u90e8\u5206&#xff0c;\u5927\u62ec\u53f7\u4e00\u5b9a\u8981\u4fdd\u8bc1\u6210\u5bf9\u51fa\u73b0\u3002<\/span><img loading=\"lazy\" decoding=\"async\" alt=\"\" class=\"right\" height=\"184\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418123249-680246718033d.png\" width=\"229\" \/><\/p>\n<\/p>\n<h6 id=\"%C2%A03.%E6%A0%B9%E6%8D%AE%E6%97%B6%E9%97%B4%E8%BE%93%E5%87%BA%E9%97%AE%E5%80%99%E8%AF%AD\">\u00a03.\u6839\u636e\u65f6\u95f4\u8f93\u51fa\u95ee\u5019\u8bed<\/h6>\n<p>\u4e0a\u9762\u6211\u4eec\u63d0\u5230\u4e86\u591a\u4e2aif\u548celse\u95ee\u9898&#xff0c;\u4e0b\u9762\u6211\u901a\u8fc7\u4ee3\u7801\u6765\u8bb2\u89e3\u5982\u4f55\u89e3\u51b3\u3002<\/p>\n<p>#include&lt;stdio.h&gt;<br \/>\nint main()<br \/>\n{<br \/>\nint time;<br \/>\nprintf(&#034;\u8bf7\u8f93\u5165\u6b64\u65f6\u7684\u65f6\u95f4&#xff1a;&#034;);<br \/>\nscanf(&#034;%d&#034;, &amp;time);<br \/>\nif (time &lt; 12)<br \/>\n{<br \/>\nprintf(&#034;\u65e9\u4e0a\u597d\\\\n&#034;);<br \/>\n}<br \/>\nelse if (time &#061;&#061; 12)<br \/>\n{<br \/>\nprintf(&#034;\u4e2d\u5348\u597d\\\\n&#034;);<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nprintf(&#034;\u665a\u4e0a\u597d\\\\n&#034;);<br \/>\n}<br \/>\nreturn 0;<br \/>\n} <\/p>\n<p>\u7a0b\u5e8f\u8fd0\u884c&#xff1a;<\/p>\n<p>\u5f53\u7528\u6237\u8f93\u5165\u7684\u6570\u503c\u5c0f\u4e8e12&#xff0c;\u7b2c\u4e00\u4e2aif\u8bed\u53e5\u5224\u65ad\u4e3a\u771f\u503c&#xff0c;\u5219\u4f1a\u6267\u884cif\u540e\u9762\u7684\u8bed\u53e5\u5757&#xff0c;\u5373\u4f1a\u6253\u5370\u51fa\u201c\u65e9\u4e0a\u597d\u201d\u7136\u540e\u8df3\u8fc7else if\u8bed\u53e5\u548celse\u8bed\u53e5&#xff1b;<\/p>\n<p>\u5f53\u7528\u6237\u8f93\u5165\u7684\u6570\u503c\u7b49\u4e8e12&#xff0c;\u7b2c\u4e00\u4e2aif\u8bed\u53e5\u5224\u65ad\u4e3a\u5047&#xff0c;\u90a3\u4e48\u5c06\u5224\u65adelse if\u8bed\u53e5\u4e2d\u7684\u8868\u8fbe\u5f0f&#xff0c;\u5982\u679c\u8868\u8fbe\u5f0f\u4e3a\u771f&#xff0c;\u5219\u4f1a\u6253\u5370\u51fa\u201c\u4e2d\u5348\u597d\u201d\u7136\u540e\u8df3\u8fc7else\u8bed\u53e5&#xff1b;<\/p>\n<p>\u5f53\u7528\u6237\u8f93\u5165\u7684\u6570\u503c\u5927\u4e8e12&#xff0c;if\u8bed\u53e5\u548celse if\u8bed\u53e5\u5224\u65ad\u4e3a\u5047&#xff0c;\u90a3\u4e48\u5c06\u4f1a\u5224\u65adelse\u8bed\u53e5\u4e2d\u7684\u8868\u8fbe&#xff0c;\u5982\u679c\u8868\u8fbe\u5f0f\u4e3a\u771f&#xff0c;\u5c06\u4f1a\u6253\u5370\u51fa\u201c\u665a\u4e0a\u597d\u201d&#xff1b;<\/p>\n<p>\u5f53\u6240\u6709\u7684\u5224\u65ad\u90fd\u4e0d\u6210\u7acb&#xff0c;\u5373\u8868\u8fbe\u5f0f\u90fd\u4e3a\u5047\u503c\u65f6&#xff0c;\u6267\u884celse\u540e\u7684\u8bed\u53e5\u5757\u3002<\/p>\n<p>\u8fd9\u6837\u6211\u4eec\u4e0a\u8ff0\u7684\u95ee\u9898\u5c31\u89e3\u51b3\u4e86<\/p>\n<p>\u6839\u636e\u6211\u81ea\u5df1\u7684\u7406\u89e3&#xff0c;\u6211\u8ba4\u4e3a\u5229\u7528else if\u8bed\u53e5\u6765\u8ba1\u7b97\u5206\u6bb5\u51fd\u6570\u7684\u503c\u662f\u975e\u5e38\u65b9\u4fbf\u7684&#xff0c;\u4e5f\u80fd\u4f7f\u6211\u4eec\u66f4\u597d\u7406\u89e3else if\u8bed\u53e5\u3002<\/p>\n<h6 id=\"4.%E8%AE%A1%E7%AE%97%E5%88%86%E6%AE%B5%E5%87%BD%E6%95%B0\">4.\u8ba1\u7b97\u5206\u6bb5\u51fd\u6570<\/h6>\n<p>\/\/\u5206\u6bb5\u51fd\u6570&#xff1a;<br \/>\n    \/\/y&#061;x(x&lt;1)<br \/>\n\/\/y&#061;2x-1(1&lt;&#061;x&lt;10)<br \/>\n\/\/y&#061;3x-12(x&gt;&#061;10)<br \/>\n#include&lt;stdio.h&gt;<br \/>\nint main()<br \/>\n{<br \/>\nint x, y;<br \/>\nprintf(&#034;\u8bf7\u8f93\u5165x\u7684\u503c&#xff1a;&#034;);<br \/>\nscanf(&#034;%d&#034;, &amp;x);<br \/>\nif (x &lt; 1)<br \/>\n{<br \/>\ny &#061; x;<br \/>\nprintf(&#034;y&#061;%d\\\\n&#034;, y);<br \/>\n}<br \/>\nelse if (x &gt;&#061; 1 &amp;&amp; x &lt; 10)<br \/>\n{<br \/>\ny &#061; 2 * x &#8211; 1;<br \/>\nprintf(&#034;y&#061;%d\\\\n&#034;, y);<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\ny &#061; 3 * x &#8211; 12;<br \/>\nprintf(&#034;y&#061;%d\\\\n&#034;, y);<br \/>\n}<br \/>\nreturn 0;<br \/>\n} <\/p>\n<h4 id=\"if%E7%9A%84%E5%B5%8C%E5%A5%97%E5%BD%A2%E5%BC%8F\">if\u7684\u5d4c\u5957\u5f62\u5f0f<\/h4>\n<h6>1.\u57fa\u672c\u5f62\u5f0f<\/h6>\n<p>if (\u8868\u8fbe\u5f0f1)<br \/>\n{<br \/>\nif (\u8868\u8fbe\u5f0f2)<br \/>\n{<br \/>\n\u8bed\u53e5\u57571<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\n\u8bed\u53e5\u57572<br \/>\n}<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\nif (\u8868\u8fbe\u5f0f3)<br \/>\n{<br \/>\n\u8bed\u53e5\u57573<br \/>\n}<br \/>\nelse<br \/>\n{<br \/>\n\u8bed\u53e5\u57574<br \/>\n}<br \/>\n} <\/p>\n<h6 id=\"2.if%E5%B5%8C%E5%A5%97%E5%BA%94%E7%94%A8\">2.if\u5d4c\u5957\u5e94\u7528<\/h6>\n<p>\u4f7f\u7528if\u8bed\u53e5\u7684\u5d4c\u5957\u5f62\u5f0f&#xff0c;\u53ef\u5c06\u5224\u65ad\u7684\u6761\u4ef6\u8fdb\u884c\u7ec6\u5316&#xff0c;\u4ece\u800c\u5b9e\u73b0\u66f4\u590d\u6742\u7684\u5224\u65ad\u548c\u64cd\u4f5c<\/p>\n<p><span style=\"color:#511b78\">if\u8bed\u53e5\u3001if&#8230;else\u8bed\u53e5\u3001else if\u8bed\u53e5\u53ef\u4ee5\u5728\u6839\u636e\u9700\u8981\u65f6\u4e92\u76f8\u5d4c\u5957\u3002\u5728\u590d\u6742\u7684\u5d4c\u5957\u4e2d\u4e00\u5b9a\u8981\u6ce8\u610fif \u4e0eelse\u7684\u914d\u5bf9\u60c5\u51b5\u3002else\u603b\u662f\u4e0e\u5176\u524d\u9762\u672a\u914d\u5bf9\u7684if\u8fdb\u884c\u914d\u5bf9<\/span><\/p>\n<p>\u00a0\u4ee5\u4e0a\u5c31\u662f\u5173\u4e8eif\u8bed\u53e5\u6240\u6709\u7684\u5185\u5bb9\u4e86&#xff0c;\u611f\u8c22\u60a8\u7684\u89c2\u770b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb3.1k\u6b21\uff0c\u70b9\u8d5e51\u6b21\uff0c\u6536\u85cf16\u6b21\u3002\u4e0a\u9762\u8fd9\u4e2a\u7a0b\u5e8f\u5b9e\u9645\u4e0a\u662f\u5b58\u5728\u4e00\u4e9b\u95ee\u9898\u7684\uff0c\u5047\u5982\u7528\u6237\u8f93\u5165\u7684\u6570\u503c\u4e3a\u5c0f\u4e8e12\u7684\u6574\u6570\uff0c\u7b2c\u4e00\u4e2a\u8bed\u53e5\u5224\u65ad\u4e3a\u771f\u503c\uff0c\u5219\u4f1a\u6267\u884c\u540e\u9762\u7684\u8bed\u53e5\u5757\u3002\u5f53\u7528\u6237\u8f93\u5165\u7684\u6570\u503c\u7b49\u4e8e12\uff0c\u7b2c\u4e00\u4e2aif\u8bed\u53e5\u5224\u65ad\u4e3a\u5047\uff0c\u90a3\u4e48\u5c06\u5224\u65adelse if\u8bed\u53e5\u4e2d\u7684\u8868\u8fbe\u5f0f\uff0c\u5982\u679c\u8868\u8fbe\u5f0f\u4e3a\u771f\uff0c\u5219\u4f1a\u6253\u5370\u51fa\u201c\u4e2d\u5348\u597d\u201d\u7136\u540e\u8df3\u8fc7else\u8bed\u53e5\uff1b\u5728if\u540e\u7684\u62ec\u53f7\u4e2d\u5224\u65ad\u8868\u8fbe\u5f0f\u7684\u7ed3\u679c\uff0c\u5982\u679c\u5224\u65ad\u7684\u7ed3\u679c\u4e3a\u771f\u503c\uff0c\u5219\u6267\u884cif\u540e\u9762\u8bed\u53e5\u5757\u7684\u5185\u5bb9\uff1b\u5f53\u7528\u6237\u8f93\u5165\u7684\u6570\u503c\u5927\u4e8e12\uff0cif\u8bed\u53e5\u548celse if\u8bed\u53e5\u5224\u65ad\u4e3a\u5047\uff0c\u90a3\u4e48\u5c06\u4f1a\u5224\u65adelse\u8bed\u53e5\u4e2d\u7684\u8868\u8fbe\uff0c\u5982\u679c\u8868\u8fbe\u5f0f\u4e3a\u771f\uff0c\u5c06\u4f1a\u6253\u5370\u51fa\u201c\u665a\u4e0a\u597d\u201d\uff1b_if else if else\u8bed\u53e5\u6d41\u7a0b\u56fe<\/p>\n","protected":false},"author":2,"featured_media":13627,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[99,87,43],"topic":[],"class_list":["post-13631","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-java","tag-87","tag-43"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u9009\u62e9\u7ed3\u6784\u7a0b\u5e8f\u8bbe\u8ba1\uff081\/3\uff09 - \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\/13631.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u9009\u62e9\u7ed3\u6784\u7a0b\u5e8f\u8bbe\u8ba1\uff081\/3\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb3.1k\u6b21\uff0c\u70b9\u8d5e51\u6b21\uff0c\u6536\u85cf16\u6b21\u3002\u4e0a\u9762\u8fd9\u4e2a\u7a0b\u5e8f\u5b9e\u9645\u4e0a\u662f\u5b58\u5728\u4e00\u4e9b\u95ee\u9898\u7684\uff0c\u5047\u5982\u7528\u6237\u8f93\u5165\u7684\u6570\u503c\u4e3a\u5c0f\u4e8e12\u7684\u6574\u6570\uff0c\u7b2c\u4e00\u4e2a\u8bed\u53e5\u5224\u65ad\u4e3a\u771f\u503c\uff0c\u5219\u4f1a\u6267\u884c\u540e\u9762\u7684\u8bed\u53e5\u5757\u3002\u5f53\u7528\u6237\u8f93\u5165\u7684\u6570\u503c\u7b49\u4e8e12\uff0c\u7b2c\u4e00\u4e2aif\u8bed\u53e5\u5224\u65ad\u4e3a\u5047\uff0c\u90a3\u4e48\u5c06\u5224\u65adelse if\u8bed\u53e5\u4e2d\u7684\u8868\u8fbe\u5f0f\uff0c\u5982\u679c\u8868\u8fbe\u5f0f\u4e3a\u771f\uff0c\u5219\u4f1a\u6253\u5370\u51fa\u201c\u4e2d\u5348\u597d\u201d\u7136\u540e\u8df3\u8fc7else\u8bed\u53e5\uff1b\u5728if\u540e\u7684\u62ec\u53f7\u4e2d\u5224\u65ad\u8868\u8fbe\u5f0f\u7684\u7ed3\u679c\uff0c\u5982\u679c\u5224\u65ad\u7684\u7ed3\u679c\u4e3a\u771f\u503c\uff0c\u5219\u6267\u884cif\u540e\u9762\u8bed\u53e5\u5757\u7684\u5185\u5bb9\uff1b\u5f53\u7528\u6237\u8f93\u5165\u7684\u6570\u503c\u5927\u4e8e12\uff0cif\u8bed\u53e5\u548celse if\u8bed\u53e5\u5224\u65ad\u4e3a\u5047\uff0c\u90a3\u4e48\u5c06\u4f1a\u5224\u65adelse\u8bed\u53e5\u4e2d\u7684\u8868\u8fbe\uff0c\u5982\u679c\u8868\u8fbe\u5f0f\u4e3a\u771f\uff0c\u5c06\u4f1a\u6253\u5370\u51fa\u201c\u665a\u4e0a\u597d\u201d\uff1b_if else if else\u8bed\u53e5\u6d41\u7a0b\u56fe\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/13631.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-18T12:32:50+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418123249-680246711357e.png\" \/>\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=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/13631.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/13631.html\",\"name\":\"\u9009\u62e9\u7ed3\u6784\u7a0b\u5e8f\u8bbe\u8ba1\uff081\/3\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-18T12:32:50+00:00\",\"dateModified\":\"2025-04-18T12:32:50+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/13631.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/13631.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/13631.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u9009\u62e9\u7ed3\u6784\u7a0b\u5e8f\u8bbe\u8ba1\uff081\/3\uff09\"}]},{\"@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":"\u9009\u62e9\u7ed3\u6784\u7a0b\u5e8f\u8bbe\u8ba1\uff081\/3\uff09 - \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\/13631.html","og_locale":"zh_CN","og_type":"article","og_title":"\u9009\u62e9\u7ed3\u6784\u7a0b\u5e8f\u8bbe\u8ba1\uff081\/3\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb3.1k\u6b21\uff0c\u70b9\u8d5e51\u6b21\uff0c\u6536\u85cf16\u6b21\u3002\u4e0a\u9762\u8fd9\u4e2a\u7a0b\u5e8f\u5b9e\u9645\u4e0a\u662f\u5b58\u5728\u4e00\u4e9b\u95ee\u9898\u7684\uff0c\u5047\u5982\u7528\u6237\u8f93\u5165\u7684\u6570\u503c\u4e3a\u5c0f\u4e8e12\u7684\u6574\u6570\uff0c\u7b2c\u4e00\u4e2a\u8bed\u53e5\u5224\u65ad\u4e3a\u771f\u503c\uff0c\u5219\u4f1a\u6267\u884c\u540e\u9762\u7684\u8bed\u53e5\u5757\u3002\u5f53\u7528\u6237\u8f93\u5165\u7684\u6570\u503c\u7b49\u4e8e12\uff0c\u7b2c\u4e00\u4e2aif\u8bed\u53e5\u5224\u65ad\u4e3a\u5047\uff0c\u90a3\u4e48\u5c06\u5224\u65adelse if\u8bed\u53e5\u4e2d\u7684\u8868\u8fbe\u5f0f\uff0c\u5982\u679c\u8868\u8fbe\u5f0f\u4e3a\u771f\uff0c\u5219\u4f1a\u6253\u5370\u51fa\u201c\u4e2d\u5348\u597d\u201d\u7136\u540e\u8df3\u8fc7else\u8bed\u53e5\uff1b\u5728if\u540e\u7684\u62ec\u53f7\u4e2d\u5224\u65ad\u8868\u8fbe\u5f0f\u7684\u7ed3\u679c\uff0c\u5982\u679c\u5224\u65ad\u7684\u7ed3\u679c\u4e3a\u771f\u503c\uff0c\u5219\u6267\u884cif\u540e\u9762\u8bed\u53e5\u5757\u7684\u5185\u5bb9\uff1b\u5f53\u7528\u6237\u8f93\u5165\u7684\u6570\u503c\u5927\u4e8e12\uff0cif\u8bed\u53e5\u548celse if\u8bed\u53e5\u5224\u65ad\u4e3a\u5047\uff0c\u90a3\u4e48\u5c06\u4f1a\u5224\u65adelse\u8bed\u53e5\u4e2d\u7684\u8868\u8fbe\uff0c\u5982\u679c\u8868\u8fbe\u5f0f\u4e3a\u771f\uff0c\u5c06\u4f1a\u6253\u5370\u51fa\u201c\u665a\u4e0a\u597d\u201d\uff1b_if else if else\u8bed\u53e5\u6d41\u7a0b\u56fe","og_url":"https:\/\/www.wsisp.com\/helps\/13631.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-18T12:32:50+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418123249-680246711357e.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/13631.html","url":"https:\/\/www.wsisp.com\/helps\/13631.html","name":"\u9009\u62e9\u7ed3\u6784\u7a0b\u5e8f\u8bbe\u8ba1\uff081\/3\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-18T12:32:50+00:00","dateModified":"2025-04-18T12:32:50+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/13631.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/13631.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/13631.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u9009\u62e9\u7ed3\u6784\u7a0b\u5e8f\u8bbe\u8ba1\uff081\/3\uff09"}]},{"@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\/13631","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=13631"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/13631\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/13627"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=13631"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=13631"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=13631"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=13631"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}