十二面体表面积程序
给定十二面体的边缘,计算其表面积。表面积是形状的所有面占据的空间量。
公式:
例子:
Input : 3
Output : 185.812
Input : 7
Output : 1011.64
十二面体是由 12 个面或平面组成的 3 维图形。所有的面都是相同大小的五边形。 “十二面体”这个词来自希腊语dodeca(“十二”)和hedron(“面”)。每个形状都有属性和特征。十二面体也是如此
- 12个相等的五边形面
- 20 个顶点
- 30 条边
其中五边形是具有 5 个直边和 5 个顶点的二维形状。因此,一个十二面体有 12 个这些平坦、相等的五边形面。因此,可以将十二面体视为 12 面骰子(通常看不到),但可以在 Battleball 棋盘游戏中。
C++
// CPP program to calculate
// surface area of dodecahedron
#include
using namespace std;
// utility Function
double area_of_dodecahedron(int side)
{
return ((3 * sqrt(25 + 10 * (sqrt(5))))
* (pow(side, 2))) ;
}
// Driver Function
int main()
{
int side = 3;
cout<< "Surface area of dodecahedron = "
<< area_of_dodecahedron(side);
return 0;
}
Java
//Java program to calculate
// surface area of dodecahedron
class GFG
{
// Utility Function
static double area_of_dodecahedron(int side)
{
return ((3 * Math.sqrt(25 + 10 * (Math.sqrt(5))))
* (Math.pow(side, 2))) ;
}
// Driver Function
public static void main (String[] args)
{
int side = 3;
System.out.println("Surface area of dodecahedron ="
+ area_of_dodecahedron(side));
}
}
// This code is contributed by Azkia Anam.
Python3
# Python program to calculate
# surface area of dodecahedron
import math
# utility Function
def area_of_dodecahedron(side):
return ((3 * math.sqrt(25 + 10 * (math.sqrt(5))))* (math.pow(side, 2)))
# Driver Function
side = 3
print("Surface area of dodecahedron = ",
round(area_of_dodecahedron(side), 3))
# This code is contributed
# by Azkia Anam.
C#
//C# program to calculate
// surface area of dodecahedron
using System;
class GFG
{
// Utility Function
static float area_of_dodecahedron(int side)
{
return (float)((3 * Math.Sqrt(25 + 10 * (Math.Sqrt(5))))
* (Math.Pow(side, 2))) ;
}
// Driver Function
public static void Main ()
{
int side = 3;
Console.WriteLine("Surface area of dodecahedron ="
+ area_of_dodecahedron(side));
}
}
// This code is contributed by vt_m.
PHP
Javascript
输出:
Surface area of dodecahedron = 185.812