落書きノート

ふと自分が気になった事を書いてます

OCamlで問題を解く

print_endline "三角形の面積を求めます。";;
print_string "底辺 : ";;
let bottom = read_float();;
print_string "高さ : ";;
let height = read_float();;

print_endline("面積は" ^ string_of_float(bottom *. height /. 2.) ^ "です。");;



let pi = 4.0 *. atan 1.0;;
print_endline "球の表面積と体積を求めます。";;
print_string "半径 : ";;
let r = read_float();;
print_endline("表面積は" ^ string_of_float(4. *. pi *. r *. r) ^ "です。");;
print_endline("体積は" ^ string_of_float(4. *. pi *. r *. r *. r /. 3.) ^ "です。");;




Random.self_init();;
let a = Random.int 9 + 1;;
print_int a;;
print_newline();;
let b = -1 - Random.int 9;;
print_int b;;
print_newline();;
let c = Random.int 90 + 10;;
print_int c;;
print_newline();;




Random.self_init();;
print_string "整数値 : ";;
let n = read_int();;
print_string("値は" ^ string_of_int(Random.int 11 + (n - 5)) ^ "です。\n");;





Random.self_init();;
let a = Random.float 1.;;
print_float a;;
print_newline();;
let b = Random.float 10.;;
print_float b;;
print_newline();;
let c = -1. +. Random.float 1. *. 2.;;
print_float c;;
print_newline();;





print_string "姓 : ";;
let sei = read_line();;
print_string "名 : ";;
let mei = read_line();;
print_string("こんにちは" ^ sei ^ mei ^ "さん。");;
print_newline();;





print_string "住所 : ";;
let address = read_line();;
print_endline("お住いは" ^ address ^ "ですね。");;





let s1 = "ABC"
let s2 = "XYZ";;

print_endline s1;;
print_endline s2;;

let s1 = "FBI";;

print_endline s1;;
print_endline s2;;