結果

問題 No.729 文字swap
ユーザー マサマサ
提出日時 2022-02-08 17:30:11
言語 Java21
(openjdk 21)
結果
AC  
実行時間 125 ms / 2,000 ms
コード長 496 bytes
コンパイル時間 2,042 ms
コンパイル使用メモリ 71,644 KB
実行使用メモリ 56,368 KB
最終ジャッジ日時 2023-09-05 17:28:26
合計ジャッジ時間 5,272 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
55,880 KB
testcase_01 AC 124 ms
55,772 KB
testcase_02 AC 121 ms
55,520 KB
testcase_03 AC 124 ms
56,016 KB
testcase_04 AC 125 ms
55,736 KB
testcase_05 AC 124 ms
55,884 KB
testcase_06 AC 124 ms
55,816 KB
testcase_07 AC 124 ms
55,852 KB
testcase_08 AC 123 ms
56,368 KB
testcase_09 AC 124 ms
55,776 KB
testcase_10 AC 124 ms
55,612 KB
testcase_11 AC 125 ms
55,992 KB
testcase_12 AC 124 ms
55,936 KB
testcase_13 AC 123 ms
55,948 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		int i = sc.nextInt();
		int j = sc.nextInt();
		
		String[] ary = new String[s.length()];
		for (int idx = 0; idx < s.length(); idx++) {
			ary[idx] = String.valueOf(s.charAt(idx));
		}
		
		String w = "";
		w = ary[i];
		ary[i] = ary[j];
		ary[j] = w;
		
		for (String value : ary) {
			System.out.print(value);
		}
		
		sc.close();
	}
}
0