JAVA 三元运算符 求最大值

package Code428;

import java.util.Scanner;

public class CodeScannerMax {

public static void main(String[] args) {
//从键盘输入三个数字
Scanner scanner =new Scanner(System.in);
int a=scanner.nextInt();
int b=scanner.nextInt();
int c =scanner.nextInt();
//使用三元运算符 a大于b,如果大于则 temp=a,否则temp=b;

int temp = a>b?a:b;
int max = c>temp?c:temp;
System.out.println("最大值"+max);
}
}
运行代码↓

 

 
posted @ 2019-04-28 19:43  Ssinoo団子  阅读(825)  评论(0编辑  收藏  举报