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

更新於: 2022-05-16

154 次瀏覽

開啟你的 職業

透過完成課程獲得認證

開始學習
廣告
© . All rights reserved.