三角形的区域,利用苍鹭的配方 [英] area of a triangle, making use of the heron's formula
问题描述
i初学者,我被要求制作一个程序,利用苍鹭的公式,以及一些关于找到三角形区域的函数的知识。我做了,但有一个问题,我无法弄清楚。它是它给出了错误的答案!!!。
i不知道为什么。我经历了该计划的每一步,没有发现任何缺陷。请帮助我找到我程序中的缺陷。
更具体一点: -
实际上我编程的方式是这样的,当我放入3三角形的两边,它通过利用苍鹭的公式来计算三角形的面积,当我给出三边的值时,它计算并给出错误的答案(错误)区域)!!
这里是代码
int ss =(se + SR + ST)/ 2;
int ree = 0 ;
ree = sqrt((ss-se)*(ss-sr)*(ss-st));
return ree;
- 这是整个程序的链接,以防你需要看看它。
链接
而不是int使用float或double。如果你使用float,那么在双重使用sqrt的情况下使用sqrtf。 double给你更高的精确度。
hey,
i am beginner, i made was asked to make a program that would make use of the heron's formula, and some knowledge regarding functions to find the area of a triangle.well, i did, but there was this one problem which i was not able to figure out.here it is " it's giving the wrong answer!!! ".
i don't know why. i went through each and every single step of the program and found no flaw. please help me find the flaw in my program.
to be a bit more specific:-
actually i programmed it in such a way that, when i give in the 3 sides of a triangle, it calculates the area of the triangle, by making use of the heron's formula,
well when i give in the values of the 3 sides, it calculates and gives the wrong answer(wrong area)!!
here's the code
int ss=(se+sr+st)/2;
int ree=0;
ree=sqrt((ss-se)*(ss-sr)*(ss-st));
return ree;
--here is the link to the whole program just in case u want to take a look at it.
link
Instead of int use float or double. If you use float then use sqrtf, in case of double use sqrt. double gives you higher precision.
这篇关于三角形的区域,利用苍鹭的配方的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!