一個 C 程式中內接於圓的十邊形面積?
正規十邊形是一個十邊多邊形,所有邊和角相等。這裡我們需求獲得一個已知半徑為 r 的內接於圓的十邊形面積,
內接於圓的十邊形邊的數學公式,
a = r√(2-2cos36o)
(使用餘弦定理)
獲得十邊形面積的公式,
Area = 5*a2*(√5+2√5)/2 Area = 5 *(r√(2-2cos36))^2*(√5+2√5)/2 Area = (5r2*(3-√5)*(√5+2√5))/4
在程式中使用此公式,
示例
#include <stdio.h>
#include <math.h>
int main() {
float r = 8;
float area = (5 * pow(r, 2) * (3 - sqrt(5))* (sqrt(5) + (2 * sqrt(5))))/ 4;
printf("area = %f",area);
return 0;
}輸出
area = 409.968933
廣告
資料結構
網路
關係資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP