标题: 键盘输入三个数,按大到小输出 [打印本页] 作者: Andyhuai 时间: 2016-3-12 22:00 标题: 键盘输入三个数,按大到小输出 import java.util.Scanner;
class ShunXi {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入三个数字:");
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
int min = ((a<=b) ? a:b)<= c ?((a<=b) ? a:b):c ;
int max = ((a>=b) ? a:b)>= c ?((a>=b) ? a:b):c ;
int mid = a + b + c - min - max;
System.out.println("按照从小到大排序后的顺序为:" + max + " " + mid + " " + min);