运算符和表达式 、 分支结构 3 个数值进行升序排列

import java.util.Scanner;
public class SortOfThree {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请依次输入三个整数:a,b,c(以空格隔开)");
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();
        scanner.close();
        System.out.println("您输入的是:");
        System.out.println("a=" + a + ", b=" + b + ", c=" + c);
        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=" + a + ", b=" + b + ", c=" + c);
    }
}
原文地址:https://www.cnblogs.com/luckyBrown/p/5840497.html