比较三个数大小

import java.util.Scanner;

public class ShuRuBiJiaoDaXiao {
public static void main(String[] args) {
//1.键盘录入3个整数
//2.创建对象
Scanner sc = new Scanner(System.in);
//3.给出友好提示
System.out.println("亲输入第一个整数");
System.out.println("亲输入第二个整数");
System.out.println("亲输入第san个整数");
//4.使用变量存储用户录入的数据
int i = sc.nextInt();
int j = sc.nextInt();
int k = sc.nextInt();
//5.先比较前2个数,得到的结果赋值给temp
int temp = i > j ? i : j;
//6.用前两个数的较大数与第三个数比较
int max = temp > k? temp : k;
System.out.println(max);

}

}

posted @ 2021-04-29 12:59  690091010  阅读(151)  评论(0)    收藏  举报