在这里,我们将看到如何获得内切于n边正多边形的圆的面积。给定n(边数),多边形的每条边为“a”

方法很简单。一个N边多边形可以被分成N个相等的三角形,每个三角形的中心角度为360/N,所以-

#include <iostream>
#include <cmath>
using namespace std;
float area(float n, float a) {
if (n < 0 || a < 0 ) //if the valuse are negative it is invalid
return -1;
float r = a/(2.0*tan((180/n) * 3.14159/180));
float area = 3.14159 * r*r;
return area;
}
int main() {
float n = 8, a = 4;
cout << "Area : " << area(n, a);
}Area : 73.2422
以上就是在C程序中,将以下内容翻译为中文:N边正多边形内切的最大圆的面积是多少?的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号