返回列表 發帖
  1. import java.util.Scanner;

  2. public class Ch01
  3. {
  4.     public static void main(String ags[])
  5.     {
  6.             int a, b, c, d, e, f, g;
  7.             Scanner s=new Scanner(System.in);
  8.            
  9.             while(true)
  10.         {
  11.                     System.out.print("請依序輸入四個數: ");
  12.                 a=s.nextInt();
  13.                 b=s.nextInt();
  14.                 c=s.nextInt();
  15.                 d=s.nextInt();
  16.                 if(a>b)
  17.                         e=a;
  18.                 else if(a<b)
  19.                         e=b;
  20.                 else
  21.                         e=a;
  22.                 if(c>d)
  23.                         f=c;
  24.                 else if(c<d)
  25.                         f=d;
  26.                 else
  27.                         f=c;
  28.                 if(e>f)
  29.                         g=e;
  30.                 else if(e<f)
  31.                         g=f;
  32.                 else
  33.                         g=e;
  34.                 System.out.println("四數中最大的數為: "+g);
  35.                 System.out.println();
  36.         }
  37.     }
  38. }
複製代碼

TOP

返回列表