返回列表 發帖
  1. import java.io.Console;

  2. public class ch17
  3. {
  4.   public static void main (String args[])
  5.   {
  6.       int a, b, c, d, max;
  7.       Console console=System.console();
  8.       System.out.print("請輸入第1個數: ");
  9.       a=Integer.parseInt(console.readLine());
  10.       max = a;
  11.       System.out.print("請輸入第2個數: ");
  12.       b=Integer.parseInt(console.readLine());
  13.       max = (b>max?b:max);
  14.       System.out.print("請輸入第3個數: ");
  15.       c=Integer.parseInt(console.readLine());
  16.       max = (c>max?c:max);
  17.       System.out.print("請輸入第4個數: ");
  18.       d=Integer.parseInt(console.readLine());
  19.       max = (d>max?d:max);

  20.       System.out.print("4數中較大的數為: " + max);
  21.   }
  22. }
複製代碼

TOP

返回列表