結果
問題 |
No.39 桁の数字を入れ替え
|
ユーザー |
|
提出日時 | 2017-04-01 09:58:54 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 502 bytes |
コンパイル時間 | 3,532 ms |
コンパイル使用メモリ | 74,764 KB |
実行使用メモリ | 41,288 KB |
最終ジャッジ日時 | 2024-07-07 18:44:34 |
合計ジャッジ時間 | 5,969 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 11 WA * 8 |
ソースコード
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); } }