情報科学概論 解答例
課題 2000.5.16 & 5.23


5-16

#!/usr/bin/ruby

def f(n)
  if n > 0
    n*n-n
  else
    n*n+n
  end
end

for i in -5..5
  print i, ", ", f(i), "\n"
end


5-23

#!/usr/bin/ruby

include Math
theta = PI/9

result = exp(theta)/2-exp(-theta)/2
print "sinh 20°= ", result, "\n"


Webテキスト(2000.6.20)へ戻る