SWEA 13428デジタル操作



https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AX4EJPs68IkDFARe
これは単純な実施問題である.
char[]配列を入力し、各位置を変更しようとします.
一番大きい時と一番小さい時に更新すればいいです.
import java.util.Scanner;
 
public class Solution {
    public static void main(String[] args) {
        int T;
        Scanner sc = new Scanner(System.in);
        T = sc.nextInt();
        for (int test_case = 1; test_case <= T; test_case++) {
            String num = sc.next();
            char[] A = num.toCharArray();
            int min = Integer.parseInt(num), max = min;
            //System.out.println(Integer.parseInt(String.valueOf(A)));
            for(int i = 0; i < A.length - 1; i++) {
                for(int j = i + 1; j < A.length; j++) {
                    char tmp = A[i];
                    A[i] = A[j];
                    A[j] = tmp;
                    if(A[0] != 48 && Integer.parseInt(String.valueOf(A)) < min) {
                        min = Integer.parseInt(String.valueOf(A));
                    }
                    if(A[0] != 48 && Integer.parseInt(String.valueOf(A)) > max) {
                        max = Integer.parseInt(String.valueOf(A));
                    }           
                    tmp = A[i];
                    A[i] = A[j];
                    A[j] = tmp;
                }
            }
             
            System.out.printf("#%d %d %d\n", test_case, min, max);
 
        }
 
     
 
    }
}