三角形的面积

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

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