結果

問題 No.39 桁の数字を入れ替え
ユーザー samplelpmassamplelpmas
提出日時 2017-01-31 13:48:06
言語 Java21
(openjdk 21)
結果
AC  
実行時間 124 ms / 5,000 ms
コード長 857 bytes
コンパイル時間 1,805 ms
コンパイル使用メモリ 74,704 KB
実行使用メモリ 54,316 KB
最終ジャッジ日時 2024-04-10 05:41:15
合計ジャッジ時間 4,757 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 109 ms
53,620 KB
testcase_01 AC 105 ms
52,688 KB
testcase_02 AC 116 ms
54,020 KB
testcase_03 AC 124 ms
53,900 KB
testcase_04 AC 105 ms
52,844 KB
testcase_05 AC 115 ms
54,164 KB
testcase_06 AC 118 ms
54,044 KB
testcase_07 AC 104 ms
53,024 KB
testcase_08 AC 116 ms
53,932 KB
testcase_09 AC 104 ms
52,804 KB
testcase_10 AC 112 ms
53,740 KB
testcase_11 AC 119 ms
54,260 KB
testcase_12 AC 115 ms
54,316 KB
testcase_13 AC 97 ms
52,512 KB
testcase_14 AC 102 ms
52,696 KB
testcase_15 AC 110 ms
53,488 KB
testcase_16 AC 122 ms
54,092 KB
testcase_17 AC 114 ms
53,984 KB
testcase_18 AC 104 ms
52,924 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int inputNumber = sc.nextInt();

        char[] inputCharArray = String.valueOf(inputNumber).toCharArray();

        int max = inputNumber;

        for (int i = 0; i < inputCharArray.length; i++) {

            for (int j = i + 1; j < inputCharArray.length; j++) {

                char temp = inputCharArray[i];
                inputCharArray[i] = inputCharArray[j];
                inputCharArray[j] = temp;

                max = Math.max(max, Integer.parseInt(String.valueOf(inputCharArray)));

                temp = inputCharArray[i];
                inputCharArray[i] = inputCharArray[j];
                inputCharArray[j] = temp;

            }

        }

        System.out.println(max);

    }

}
0