結果
| 問題 |
No.163 cAPSlOCK
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-10-23 16:37:05 |
| 言語 | OCaml (5.2.1) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 611 bytes |
| コンパイル時間 | 425 ms |
| コンパイル使用メモリ | 17,408 KB |
| 最終ジャッジ日時 | 2024-11-14 19:53:01 |
| 合計ジャッジ時間 | 823 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
File "Main.ml", line 13, characters 14-17:
13 | let c = buf.[idx] in
^^^
Error: This expression has type bytes but an expression was expected of type
string
ソースコード
type case = Lower | Upper | Other
let case_of_char c =
if 'a' <= c && c <= 'z' then Lower
else if 'A' <= c && c <= 'Z' then Upper
else Other
let solve s =
let buf = Bytes.of_string s in
let blen = Bytes.length buf in
let rec solve' idx =
if idx < blen then (
let c = buf.[idx] in
let cc = match case_of_char c with
| Lower -> Char.uppercase c
| Upper -> Char.lowercase c
| Other -> failwith "hoge"
in
Bytes.set buf idx cc;
solve' (idx + 1)
)
in solve' 0;
Bytes.to_string buf
let () =
let s = read_line () in
solve s |> print_endline