結果

問題 No.39 桁の数字を入れ替え
ユーザー kano_town
提出日時 2014-11-21 19:29:10
言語 Java
(openjdk 23)
結果
AC  
実行時間 127 ms / 5,000 ms
コード長 560 bytes
コンパイル時間 3,431 ms
コンパイル使用メモリ 75,012 KB
実行使用メモリ 41,640 KB
最終ジャッジ日時 2024-10-02 05:57:57
合計ジャッジ時間 6,569 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Yukicoder39 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] c = sc.next().toCharArray();
		
		char buf;
		int max = Integer.parseInt(String.valueOf(c));
		for (int i = 0; i < c.length - 1; i++) {
			for (int j = i + 1; j < c.length; j++) {
				buf = c[i];
				c[i] = c[j];
				c[j] = buf;

				max = Math.max(max, Integer.parseInt(String.valueOf(c)));
				
				buf = c[i];
				c[i] = c[j];
				c[j] = buf;

			}
		}
		System.out.println(max);
	}
}
0