結果

問題 No.163 cAPSlOCK
ユーザー t__nabet__nabe
提出日時 2020-03-13 17:26:35
言語 Swift
(5.10.0)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 572 bytes
コンパイル時間 2,986 ms
コンパイル使用メモリ 101,620 KB
実行使用メモリ 7,692 KB
最終ジャッジ日時 2023-08-20 14:15:19
合計ジャッジ時間 4,558 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,296 KB
testcase_01 AC 3 ms
7,496 KB
testcase_02 AC 3 ms
7,380 KB
testcase_03 AC 4 ms
7,524 KB
testcase_04 AC 3 ms
7,608 KB
testcase_05 AC 3 ms
7,484 KB
testcase_06 AC 3 ms
7,412 KB
testcase_07 AC 3 ms
7,588 KB
testcase_08 AC 3 ms
7,620 KB
testcase_09 AC 3 ms
7,452 KB
testcase_10 AC 3 ms
7,276 KB
testcase_11 AC 3 ms
7,460 KB
testcase_12 AC 3 ms
7,512 KB
testcase_13 AC 3 ms
7,676 KB
testcase_14 AC 3 ms
7,536 KB
testcase_15 AC 3 ms
7,420 KB
testcase_16 AC 3 ms
7,464 KB
testcase_17 AC 3 ms
7,692 KB
testcase_18 AC 3 ms
7,368 KB
testcase_19 AC 3 ms
7,576 KB
testcase_20 AC 3 ms
7,528 KB
testcase_21 AC 3 ms
7,412 KB
testcase_22 AC 3 ms
7,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

func swapCase(string: String) -> String {
    var swappedCaseString: String = ""
    for character in string {
        switch character {
        case "a"..."z":
            let uppercaseCharacter = (String(character)).uppercased()
            swappedCaseString += uppercaseCharacter
        case "A"..."Z":
            let lowercaseCharacter = (String(character)).lowercased()
            swappedCaseString += lowercaseCharacter
        default:
            fatalError()
        }
    }
    return swappedCaseString
}

let str = readLine()!
print(swapCase(string: str))

0