- import java.io.Console;
- public class ch17
- {
- public static void main (String args[])
- {
- int a, b, bigger;
- Console console=System.console();
- System.out.print("請輸入第1個數: ");
- a=Integer.parseInt(console.readLine());
- System.out.print("請輸入第2個數: ");
- b=Integer.parseInt(console.readLine());
- bigger=(a>b)?a:b;
- System.out.print("兩數中較大的數為: "+bigger);
- }
- }
複製代碼 |