@@ -0,0 +1,764 @@
+import java.util.Arrays;%0Aimport java.util.Scanner;%0A%0Apublic class Main %7B%0A%0A    public static void main(String%5B%5D args) %7B%0A%0A        Scanner sc = new Scanner(System.in);%0A%0A        int n = sc.nextInt();%0A%0A        for (int i = 0; i %3C n; i++) %7B%0A%0A            char%5B%5D numbers = sc.next().toCharArray();%0A%0A            Arrays.sort(numbers);%0A%0A            int min = 0;%0A            int max = 0;%0A%0A            int minDigit = 10000000;%0A            int maxDigit = 1;%0A%0A            for (int j = 0; j %3C 8; j++) %7B%0A%0A                int number = numbers%5Bj%5D - '0';%0A%0A                min += number * minDigit;%0A                max += number * maxDigit;%0A%0A                minDigit /= 10;%0A                maxDigit *= 10;%0A%0A            %7D%0A%0A            System.out.println(max - min);%0A%0A        %7D%0A%0A    %7D%0A%0A%7D%0A

Create : 0051