如何在 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.