给定3个数a,b和c,输出最大的数。
import java.util.Scanner;
public class sangeshu {
public static void main(String[] args) {
System.out.println("请输入三个数:");
Scanner scanner = new Scanner(System.in);
int a = scanner.nextInt();
int b = scanner.nextInt();
int c = scanner.nextInt();
System.out.println("三个数中最大是:" + max(a, b, c));
}
private static int max(int a, int b, int c) {
int max;
max = a;
max = (b > max) ? b : max;
max = (c > max) ? c : max;// TODO Auto-generated method stub
return max;
}
}