如何在 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
推廣內容
資料結構
網路
關係資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 語言程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP