返回列表 發帖
  1. import java.io.Console;
  2. public class ch18
  3. {
  4.   public static void main (String args[])
  5.   {
  6.       int a, b, c, d, biga, bigb, bigi;
  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.       System.out.print("請輸入第3個數: ");
  13.       c=Integer.parseInt(console.readLine());
  14.       System.out.print("請輸入第4個數: ");
  15.       d=Integer.parseInt(console.readLine());

  16.       biga=(a>b)?a:b;
  17.       bigb=(c>d)?c:d;
  18.       bigi=(biga>bigb)?biga:bigb;

  19.       System.out.print("兩數中較大的數為: "+bigi);
  20.   }
  21. }
複製代碼

TOP

返回列表