結果

問題 No.784 「,(カンマ)」
ユーザー MaboyMaboy
提出日時 2021-06-18 10:48:32
言語 Swift
(5.10.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 215 bytes
コンパイル時間 1,177 ms
コンパイル使用メモリ 106,172 KB
実行使用メモリ 7,800 KB
最終ジャッジ日時 2023-09-04 00:28:45
合計ジャッジ時間 2,146 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
7,556 KB
testcase_01 AC 3 ms
7,428 KB
testcase_02 AC 3 ms
7,728 KB
testcase_03 AC 3 ms
7,768 KB
testcase_04 AC 3 ms
7,736 KB
testcase_05 AC 3 ms
7,468 KB
testcase_06 AC 3 ms
7,756 KB
testcase_07 AC 3 ms
7,616 KB
testcase_08 AC 3 ms
7,680 KB
testcase_09 AC 3 ms
7,472 KB
testcase_10 AC 3 ms
7,432 KB
testcase_11 AC 3 ms
7,744 KB
testcase_12 AC 3 ms
7,800 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

let n = Array(readLine()!).map{String($0)}
var c = n.count % 3 == 0 ? 3 : n.count % 3
var s = ""

for i in n{
    s += i
    c -= 1
    if c == 0{
        s += ","
        c = 3
    }
}
print(s.prefix(s.count - 1))
0