三目运算符
格式:布尔值?值1:值2;
题目:使用三目运算符对三个整数进行排序
import java.util.Scanner;
public class test{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int number1 = sc.nextInt();//
int number2 = sc.nextInt();//
int number3 = sc.nextInt();//
int max,min;
max = number1>number2?number1>number3?number1:number3:number2>number3?number2:number3;
min = number1<number2?number1<number3?number1:number3:number2<number3?number2:number3;
System.out.println(max+">"+(number1+number2+number3-max-min)+">"+min);
}
}