{"id":125,"date":"2017-02-18T21:31:00","date_gmt":"2017-02-18T13:31:00","guid":{"rendered":"https:\/\/cn1.club\/?p=125"},"modified":"2025-03-13T20:11:18","modified_gmt":"2025-03-13T12:11:18","slug":"day3-%e7%ac%94%e8%ae%b0-%e9%80%89%e6%8b%a9%e7%bb%93%e6%9e%84switch%e8%af%ad%e5%8f%a5%e7%9a%84%e7%bb%83%e4%b9%a0","status":"publish","type":"post","link":"http:\/\/cn1.club\/?p=125","title":{"rendered":"Day3 \u7b14\u8bb0 \u9009\u62e9\u7ed3\u6784Switch\u8bed\u53e5\u7684\u7ec3\u4e60"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code class=\"prettyprint\" >import java.util.Scanner;\nclass Test1_Switch {\n\tpublic static void main(String&#091;] args) {\n\t\tScanner sc = new Scanner(System.in);\n\t\tSystem.out.println(&quot;\u8bf7\u8f93\u5165\u660e\u5929\u4f60\u60f3\u8fc7\u5468\u51e0?&#091;\u6570\u5b57 1 - 7 ] ... &quot;);\n\t\tint week = sc.nextInt();\n\t\tswitch (week) {\n\t\tcase 1:\n\t\t\tSystem.out.println(&quot;\u661f\u671f\u4e00&quot;);\n\t\tbreak;\n\t\tcase 2:\n\t\t\tSystem.out.println(&quot;\u661f\u671f\u4e8c&quot;);\n\t\tbreak;\n\t\tcase 3:\n\t\t\tSystem.out.println(&quot;\u661f\u671f\u4e09&quot;);\n\t\tbreak;\n\t\tcase 4:\n\t\t\tSystem.out.println(&quot;\u661f\u671f\u56db&quot;);\n\t\tbreak;\n\t\tcase 5:\n\t\t\tSystem.out.println(&quot;\u661f\u671f\u4e94&quot;);\n\t\tbreak;\n\t\tcase 6:\n\t\t\tSystem.out.println(&quot;\u661f\u671f\u516d&quot;);\n\t\tbreak;\n\t\tcase 7:\n\t\t\tSystem.out.println(&quot;\u661f\u671f\u65e5&quot;);\n\t\tdefault:\n\t\t\tSystem.out.println(&quot;\u8f93\u5165\u4e86\u9519\u8bef\u7684\u503c!(1-7)&quot;);\n\t\t\n\t\t}\n\t}\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"prettyprint\" >class Test2_Switch {\n\tpublic static void main(String&#091;] args) {\n\t\t\t\/\/A,\u770b\u7a0b\u5e8f\u5199\u7ed3\u679c\n\t\t\t\/*\n\t\t\tint x = 2;\n\t\t\tint y = 3;\n\t\t\tswitch(x){\n\t\t\t\tdefault:\n\t\t\t\t\ty++;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 3:\n\t\t\t\t\ty++;\n\t\t\t\tcase 4:\n\t\t\t\t\ty++;\n\t\t\t}\n\t\t\t\/\/y\u5728default\u5904+1\u53d8\u4e3a4\n\t\t\tSystem.out.println(&quot;y=&quot;+y);\n\n\t\t\t*\/\n\t\t\t\n\t\t\t\/\/b.\u770b\u7a0b\u5e8f\u5199\u7ed3\u679c\n\t\t\tint x = 2;\n\t\t\tint y = 3;\n\t\t\tswitch(x){\n\t\t\t\tdefault:\n\t\t\t\t\ty++;\n\t\t\t\tcase 3:\n\t\t\t\t\ty++;\n\t\t\t\tcase 4:\n\t\t\t\t\ty++;\n\t\t\t}\n\t\t\t\/\/\u56e0\u4e3a\u6ca1\u6709break\u9694\u65ad\u7b26,Y\u52a0\u4e86\u4e09\u6b21 1 \u53d8\u4e3a 6\n\t\t\tSystem.out.println(&quot;y=&quot;+y);\n\n\n\n\n\n\n\t}\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":196,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[5],"tags":[],"class_list":["post-125","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-xuexi"],"_links":{"self":[{"href":"http:\/\/cn1.club\/index.php?rest_route=\/wp\/v2\/posts\/125","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/cn1.club\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/cn1.club\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/cn1.club\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/cn1.club\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=125"}],"version-history":[{"count":0,"href":"http:\/\/cn1.club\/index.php?rest_route=\/wp\/v2\/posts\/125\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/cn1.club\/index.php?rest_route=\/wp\/v2\/media\/196"}],"wp:attachment":[{"href":"http:\/\/cn1.club\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=125"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/cn1.club\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=125"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/cn1.club\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=125"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}