結果

問題 No.39 桁の数字を入れ替え
ユーザー shinwisteriashinwisteria
提出日時 2017-04-01 09:58:54
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 502 bytes
コンパイル時間 3,803 ms
コンパイル使用メモリ 72,540 KB
実行使用メモリ 56,488 KB
最終ジャッジ日時 2023-09-22 01:54:53
合計ジャッジ時間 6,892 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
55,720 KB
testcase_01 AC 124 ms
55,492 KB
testcase_02 AC 122 ms
55,524 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 120 ms
54,068 KB
testcase_08 AC 120 ms
55,728 KB
testcase_09 AC 121 ms
55,748 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 121 ms
55,716 KB
testcase_15 AC 118 ms
55,800 KB
testcase_16 AC 118 ms
55,680 KB
testcase_17 AC 119 ms
55,948 KB
testcase_18 AC 118 ms
56,488 KB
権限があれば一括ダウンロードができます

ソースコード

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 i = 9;i > Integer.parseInt(str.substring(0, 1));i--){
			String I = Integer.toString(i);
			if(str.lastIndexOf(I) > 0){
				int k = str.lastIndexOf(I);
				char keep = str.charAt(k);
				str.setCharAt(k, str.charAt(0));
				str.setCharAt(0, keep);
			}
		}
		System.out.println(str);

	}

}
0