C++ 中求二十面體的表面積和體積的程式
在這個問題中,我們給出一個值,表示二十面體的邊長。我們的任務是建立一個程式,用 C++ 語言求出二十面體的表面積和體積。
二十面體是具有 30 個面的正多面體。它有 20 個相等的等邊三角形,只有 12 個頂點。

虛線表示位於可見表面後面的邊。
我們以一個例子來理解這個問題,
輸入
a = 4
程式說明了我們解決方案的工作原理,
示例
#include <iostream>
using namespace std;
float calcIcoSArea(float a) {
return (8.660 * a * a);
}
float calcIcoVolume(float a) {
return (2.1817 * a * a * a);
}
int main(){
float a = 7;
cout<<"The length of side of icosahedron is "<<a<<endl;
cout<<"The surface area of icosahedron is "<<calcIcoSArea(a)<<endl;
cout<<"The volume of icosahedron is "<<calcIcoVolume(a)<<endl;
return 0;
}輸出
The length of side of icosahedron is 7 The surface area of icosahedron is 424.34 The volume of icosahedron is 748.323
廣告
資料結構
網路
關係型資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP