题目:输入3个数a,b,c,按大小顺序输出
public class _034Sorting { public static void main(String[] args) {
sorting();
} private static void sorting() {
Scanner scanner = new Scanner(System.in);
System.out.println("请输入3个整数:"); int a = scanner.nextInt();
int b = scanner.nextInt();
int c = scanner.nextInt();
int temp = 0; if (a < b) {
temp = a;
a = b;
b = temp;
} if (a < c) {
temp = a;
a = c;
c = temp;
} if (b < c) {
temp = b;
b = c;
c = temp;
} System.out.println("三个数从大到小的顺序输出是:");
System.out.println(a + "," + b + "," + c);
} }