首页 > 文章列表 > 在C程序中,将等边三角形内切圆的面积计算出来

在C程序中,将等边三角形内切圆的面积计算出来

c语言 等边三角形 内切圆 面积计算
499 2023-08-27

在这里我们将看到等边三角形内切圆的面积。三角形的边是“a”。

在C程序中,将等边三角形内切圆的面积计算出来

等边三角形的面积 -

在C程序中,将等边三角形内切圆的面积计算出来

三角形的半周长是 -

所以圆的半径是 -

示例

#include <iostream>
#include <cmath>
using namespace std;
float area(float a) {
   if (a < 0 ) //if the value is negative it is invalid
      return -1;
   float area = 3.1415 * (a/(2*sqrt(3))) * (a/(2*sqrt(3)));
   return area;
}
int main() {
   float a = 4;
   cout << "Area is: " << area(a);
}

输出

Area is: 4.18867