public class AssumeCorrect01 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int a= scanner.nextInt();
int b= scanner.nextInt();
int c= scanner.nextInt();
int max=0;
//int max = a > b ? (a > c ? a : c) :(b > c ? b : c); //三目运算符解法逻辑不够清晰
max=a;//把a赋值给max,假设它是最大值
if(b>max) max=b;//如果b比max大,那么就把b的值赋值给max
if(c>max) max=c;//如果c比max大,那么就把c的值赋值给max
System.out.println(max);
}
}
输入数值:
20 155 31
输出结果:
155