首页 > 文章列表 > 在C程序中,将以下内容翻译为中文:直角三角形的外接圆面积

在C程序中,将以下内容翻译为中文:直角三角形的外接圆面积

直角三角形 面积 外接圆
286 2023-08-27

这里我们将了解如何获取直角三角形的外接圆面积。三角形的斜边形成圆的直径。因此,如果斜边为 h,则半径为 h/2

在C程序中,将以下内容翻译为中文:直角三角形的外接圆面积

所以面积为 -

示例代码

#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