- import java.util.Scanner;
- public class Ch10 {
- public static void main(String[] args) {
- int a, b, c, d, e, f, g;
- Scanner s=new Scanner(System.in);
- System.out.print("請依序輸入四個數: ");
- a=s.nextInt();
- b=s.nextInt();
- c=s.nextInt();
- d=s.nextInt();
- e=a>b?a:b;
- f=c>d?c:d;
- g=e>f?e:f;
- System.out.println("最大的數是: "+g);
- }
- }
複製代碼 |