返回列表 發帖
  1. import java.io.Console;
  2. public class ch18
  3. {
  4.   public static void main(String args[])
  5.   {
  6.     int a, b, c, d, pigger ;
  7.     int ab, cd;
  8.     Console keyin=System.console();
  9.      System.out.println("四數中找出較大的數 ");
  10.      System.out.println("請輸入第一數 : ");
  11.      a = Integer.parseInt(keyin.readLine());
  12.      System.out.println("請輸入第二數 : ");
  13.      b = Integer.parseInt(keyin.readLine());
  14.      System.out.println("請輸入第三數 : ");
  15.      c = Integer.parseInt(keyin.readLine());
  16.      System.out.println("請輸入第四數 : ");
  17.      d = Integer.parseInt(keyin.readLine());
  18.      
  19.      ab=(a>b)?a:b;
  20.      cd=(c>d)?c:d;
  21.      pigger=(ab>cd)?ab:cd;
  22.      System.out.println("最大數為"+ pigger);

  23.   }
  24. }
複製代碼

TOP

返回列表