标题: 键盘录入三个整数,按照从小到大的顺序输出 [打印本页] 作者: liyansong2016 时间: 2016-6-6 22:25 标题: 键盘录入三个整数,按照从小到大的顺序输出 import java.util.Scanner;
class Test14 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("请输入第一个数:");
int a = sc.nextInt();
System.out.print("请输入第二个数:");
int b = sc.nextInt();
System.out.print("请输入第仨数:");
int c = sc.nextInt();
int max = (a>b)?((a>c)?a:c):((b>c)?b:c);
int min = (a<b)?((a<c)?a:c):((b<c)?b:c);
int z = a + b + c - max - min;
System.out.println("按照从小到大排序后的顺序为:"+min+","+z+","+max);