如何在 C 語言專案中求直角三角形外接圓的面積?


我們將在此處瞭解如何求直角三角形外接圓的面積。三角形的斜邊形成圓的直徑。因此,如果斜邊為 h,則半徑為 h/2

因此,面積為 −

示例程式碼

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

輸出

Area : 50.264

更新於: 20-8-2019

144 次檢視

開啟 職業生涯

完成課程獲得證書

開始學習
推廣內容
© . All rights reserved.