回覆列表
  • 1 # 使用者2562339713923

    推薦下載ide!!!!!! 此程式碼諸多錯誤 只是解決問題的需要 class,interface或enum的話,就是你打多了一個後括號, 另外bugs: 0. sex=1 是賦值不是比較,請使用 == 1. 最後的 else 為啥有一個 ; 導致java 認為最後的 "請重新輸入" 不是在 else 塊裡的 2. 沒有使用 if-elseif bug修復後代碼: public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.println("MSG: 1"); int sex = in.nextInt(); if (sex == 1) { System.out.println("石頭"); } else if (sex == 2) { System.out.println("剪刀"); } else if (sex == 3) { System.out.println("布"); } else { System.out.println("請重新輸入"); } } switch鏈: public static void main0(String[] args) { Scanner in = new Scanner(System.in); System.out.println("MSG: 1"); int sex = in.nextInt(); switch(sex){ case 1: System.out.println("石頭"); break; case 2: System.out.println("剪刀"); break; case 3: System.out.println("布"); break; default: System.out.println("請重新輸入"); break; } }

  • 中秋節和大豐收的關聯?
  • 怎樣寫上課說話檢討?