获取三个数据的最大值:

class Hello2 {
    public static void main(String[] args) {
        int a = 10;
        int b = 20;
        int c = 30;
        int max;
        if (a > b){
            if (a > c)
            {
                max = a;
            }else {
                max = c;
            }
        }else {
            if (b < c)
            {
                max = c;
            }else {
                max = b;
            }
        }
        System.out.println("max = " + max);
    }
}

结果:

if语句的嵌套使用之获取三个数据的最大值

 

相关文章:

  • 2022-12-23
  • 2021-11-30
  • 2022-12-23
  • 2022-12-23
  • 2022-02-28
  • 2021-11-29
  • 2022-01-21
  • 2022-12-23
猜你喜欢
  • 2021-11-23
  • 2022-12-23
  • 2021-06-07
  • 2021-06-08
  • 2022-02-03
  • 2021-08-21
  • 2022-12-23
相关资源
相似解决方案