結果

問題 No.729 文字swap
ユーザー kohaku_kohaku
提出日時 2019-02-19 18:15:23
言語 Java
(openjdk 23)
結果
AC  
実行時間 141 ms / 2,000 ms
コード長 504 bytes
コンパイル時間 2,110 ms
コンパイル使用メモリ 74,240 KB
実行使用メモリ 54,352 KB
最終ジャッジ日時 2024-10-12 13:07:20
合計ジャッジ時間 4,606 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {

    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int i = sc.nextInt();
        int j = sc.nextInt();
        System.out.println(exchange(s,i,j));
    }
    
    static String exchange(String s, int i, int j) {
        char [] arr = s.toCharArray();
        char tmp = arr[i];
        arr[i] = arr[j];
        arr[j] = tmp;
        return String.valueOf(arr);
    }
}
0