三角形的面积

2014-12-28 0 916
三角形的面积
def triangle(x,y,z)
  angleX=Math.acos((y**2+z**2-x**2)*3.14/(360*y*z))
  #angleX is the angle between side y and side z
  #This angle is calculated using angle/oppositeSide ratio
  h=z*Math.sin(angleX)
  #Here h is the height of apex Y from side y
  area=(y*h)/2.0
  puts "The area of the triangle is "+area.to_s
end

遇见资源网 ruby 三角形的面积 http://www.ox520.com/16215.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务