Java實現(xiàn) 輸入3個數(shù)a,b和c,輸出最大的數(shù)
package ceshi;
import java.util.Scanner;
public class test10051 {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);?
? ? ? ? System.out.print("分別輸入a,b,c的值:");?
? ? ? ? int a =s.nextInt();
? ? ? ? int b =s.nextInt();
? ? ? ? int c =s.nextInt();
? ? ? ? s.close();
System.out.println("a,b,c的值分別為:" + a + " "+ b + " "+ c);
int max = 0;
if(a < b) {
max = b;
}?
if(max < c) {
max = c;
}
System.out.println("三個數(shù)中的最大為" + max);
}
}
標簽: