Update all new Tasks
This commit is contained in:
parent
00a190b0a6
commit
91df62d461
5697 changed files with 93386 additions and 804 deletions
25
Task/Odd-word-problem/OCaml/odd-word-problem.ocaml
Normal file
25
Task/Odd-word-problem/OCaml/odd-word-problem.ocaml
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
let is_alpha c =
|
||||
c >= 'a' && c <= 'z' ||
|
||||
c >= 'A' && c <= 'Z'
|
||||
|
||||
let rec odd () =
|
||||
let c = input_char stdin in
|
||||
if is_alpha c
|
||||
then (let e = odd () in print_char c; e)
|
||||
else (c)
|
||||
|
||||
let rec even () =
|
||||
let c = input_char stdin in
|
||||
if is_alpha c
|
||||
then (print_char c; even ())
|
||||
else print_char c
|
||||
|
||||
let rev_odd_words () =
|
||||
while true do
|
||||
even ();
|
||||
print_char (odd ())
|
||||
done
|
||||
|
||||
let () =
|
||||
try rev_odd_words ()
|
||||
with End_of_file -> ()
|
||||
Loading…
Add table
Add a link
Reference in a new issue