結果

問題 No.39 桁の数字を入れ替え
ユーザー ルッツファン
提出日時 2015-11-28 08:30:49
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 873 bytes
コンパイル時間 3,298 ms
コンパイル使用メモリ 74,536 KB
実行使用メモリ 50,112 KB
最終ジャッジ日時 2024-09-14 04:36:23
合計ジャッジ時間 4,847 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 15 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class yukicoder014 {
	public static void main(String[] args){
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String tes = null;
		
		try {
			tes = br.readLine();
			} catch (IOException e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
		}
		
		char[] tmp = tes.toCharArray();
		
		char s = '1';
		int num = -1;
		
		for(int i = 0;i<tmp.length;i++){
			if(tmp[i] >= s){
				s = tmp[i];
				num = i;
			}
		}
		char aaa = 0;
		
		
		for(int i = 0;i<tmp.length;i++){
			if(num == 0){
				break;
			}
			if(tmp[i] < s){
				aaa = tmp[i];
				
				tmp[i] = s;
				
				tmp[num] = aaa;
				
				
				break;
			}
		}
		
		
		
		
		
		System.out.println(String.copyValueOf(tmp));
		
		
		
	}

}
0