結果
問題 | No.729 文字swap |
ユーザー |
|
提出日時 | 2021-03-18 20:05:18 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 154 ms / 2,000 ms |
コード長 | 536 bytes |
コンパイル時間 | 2,516 ms |
コンパイル使用メモリ | 76,188 KB |
実行使用メモリ | 42,520 KB |
最終ジャッジ日時 | 2024-11-17 01:57:27 |
合計ジャッジ時間 | 5,307 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 11 |
ソースコード
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String s = sc.next(); //abc int n = sc.nextInt(); //0 int m = sc.nextInt(); //2 String ans = ""; for (int i = 0; i < s.length(); i++) { if (i == n) { ans += s.substring(m, m + 1); } else if (i == m) { ans += s.substring(n, n + 1); } else{ ans += s.charAt(i); } } System.out.println(ans); sc.close(); } }