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);
}
}
如果我想把变量名也一起打印出来,有什么简单的方法吗?? |
|