三角形中內接圓的面積( C程式)?


在這裡,我們將看到內接於等邊三角形的圓的面積。三角形的邊長為“a”。

等邊 三角形的面積為 -

三角形的半周長為 -

所以,圓的半徑為 -

示例

#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

更新時間: 20-8-2019

244 次瀏覽

開啟你的職業生涯

完成課程即可獲得認證

開始
廣告
© . All rights reserved.