本帖最後由 tonyh 於 2012-10-8 20:33 編輯
- import java.io.Console;
- public class ch18
- {
- public static void main (String args[])
- {
- int a, b, c, d, e, f, g;
- Console console=System.console();
- System.out.print("請輸入第1個數: ");
- a=Integer.parseInt(console.readLine());
- System.out.print("請輸入第2個數: ");
- b=Integer.parseInt(console.readLine());
- System.out.print("請輸入第3個數: ");
- c=Integer.parseInt(console.readLine());
- System.out.print("請輸入第4個數: ");
- d=Integer.parseInt(console.readLine());
- e=(a>b)?a:b;
- f=(c>d)?c:d;
- g=(e>f)?e:f;
- System.out.print("四數中最大的數為: "+g);
- }
- }
複製代碼 |