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
用户登录
还没有账号?立即注册
用户注册
投稿取消
文章分类: |
|
还能输入300字
上传中....