gpt4 book ai didi

java - 仅使用一个 if 条件找到两个中最大的数字?

转载 作者:行者123 更新时间:2023-12-01 04:49:29 26 4
gpt4 key购买 nike

今天是我在学院的 Java 开发人员类(class)的第一个类。讲师向全类提出了一个问题:

Find the biggest number among two numbers by using only one condition, i.e., if condition only. Do not use any other conditions like using if-else, else-if, using if two times, ternary, loops, etc.

最佳答案

int max = a;

if (b > a) {
max = b;
}

关于java - 仅使用一个 if 条件找到两个中最大的数字?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59479386/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com