如何设计一个程序运算三角形面积的方法

2024年06月24日 阅读 (56)

(一)程序代码:

#includeiostream

#includecmath

#includeiomanip

using namespace std;

int main()

{

double a,b,c;

cout"Enter a,b,c";

cinabc;

if(a+bc&&a+cb&&b+ca)

{

double p,area;

p=0.5*(a+b+c);

area=sqrt(p*(p-a)*(p-b)*(p-c));

cout"三角形的面积为:"setiosflags(ios::fixed)setprecision(5)area"——利用海伦公式计算三角形面积"endl;

}

else

cout"It is not a trilateral!"endl。

郑重声明:玄微运势的内容来自于对中国传统文化的解读,对于未来的预测仅供参考。