三角形的面积
- 作者: 贫道化缘不化斋
- 来源: 51数据库
- 2022-08-12
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
推荐阅读