結果

問題 No.39 桁の数字を入れ替え
ユーザー shinwisteriashinwisteria
提出日時 2017-04-01 10:02:47
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 571 bytes
コンパイル時間 3,042 ms
コンパイル使用メモリ 71,920 KB
実行使用メモリ 56,652 KB
最終ジャッジ日時 2023-09-22 01:54:59
合計ジャッジ時間 6,199 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
56,284 KB
testcase_01 AC 114 ms
55,752 KB
testcase_02 AC 114 ms
55,848 KB
testcase_03 AC 114 ms
56,108 KB
testcase_04 AC 115 ms
55,648 KB
testcase_05 AC 115 ms
55,812 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 114 ms
56,084 KB
testcase_09 AC 113 ms
55,812 KB
testcase_10 AC 113 ms
56,372 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 116 ms
55,460 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Ketairekae {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		StringBuilder str = new StringBuilder(s.nextLine());
		s.close();
		for(int j = 0;j < str.length()-1;j++){
			for(int i = 9;i > Integer.parseInt(str.substring(j, j+1));i--){
				String I = Integer.toString(i);
				if(str.lastIndexOf(I) > j){
					int k = str.lastIndexOf(I);
					char keep = str.charAt(k);
					str.setCharAt(k, str.charAt(j));
					str.setCharAt(j, keep);
					break;
				}
			}
		}
		System.out.println(str);

	}

}
0