在这里我们将了解如何使用对角线长度来获取一个六边形的面积。六边形的对角线长度为 d。
正六边形的内角各为 120°。所有内角之和为 720°。如果对角线为 d,则面积为 -
#include <iostream> #include <cmath> using namespace std; float area(float d) { if (d < 0) //if d is negative it is invalid return -1; float area = (3 * sqrt(3) * d*d)/8.0; return area; } int main() { float r = 10; cout << "Area : " << area(r); }
Area : 64.9519
以上就是给定对角线长度的六边形的C程序的面积是多少?的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号