返回列表 發帖

兩數中找出較大的數

  1. import java.io.Console;
  2. public class ch17
  3. {
  4.   public static void main (String args[])
  5.   {
  6.       int a, b, bigger;
  7.       Console console=System.console();
  8.       System.out.print("請輸入第1個數: ");
  9.       a=Integer.parseInt(console.readLine());
  10.       System.out.print("請輸入第2個數: ");
  11.       b=Integer.parseInt(console.readLine());
  12.       bigger=(a>b)?a:b;
  13.       System.out.print("兩數中較大的數為: "+bigger);
  14.   }
  15. }
複製代碼

返回列表