首页 > 文章列表 > 圆内内接十边形的C程序的面积?

圆内内接十边形的C程序的面积?

C程序 面积 圆内接十边形
470 2023-08-31

在这里,我们将了解如何获取圆内的十边形面积。半径已给出。十边形的边是“a”。

圆内内接十边形的C程序的面积?

众所周知,十边形的边长如下 -

圆内内接十边形的C程序的面积?

示例

#include <iostream>
#include <cmath>
using namespace std;
float area(float r) {
   if (r < 0) //if r is negative it is invalid
      return -1;
   float area = (5 * pow(r, 2) * (3 - sqrt(5)) * (sqrt(5) + (2 * sqrt(5)))) / 4;
   return area;
}
int main() {
   float r = 8;
   cout << "Area : " << area(r);
}

输出

Area : 409.969