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