public class Demo02ScannerSum {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入第一个数字:");
        int a = sc.nextInt();
        System.out.println("请输入第二个数字:");
        int b = sc.nextInt();
        System.out.println("请输入第三个数字:");
        int c = sc.nextInt();
        //首先得到前两个最大值
        int temp = a > b ? a : b;
        //再让原来的最大值和第三个值对比
        int temp2 = temp > c ? temp : c;
        System.out.println("最大值为"+temp2);
    }
}

 

posted on 2021-01-13 21:01  wangchw  阅读(1777)  评论(0)    收藏  举报