考虑到二十面体的一面。任务是找到给定二十面体的面积和体积。
例子:
Input : a = 5
Output : Area: 216.506
Volume: 272.712
Input : a = 10
Output : Area: 866.0254
Volume: 2181.695
在几何学上,二十面体是规则的多面体,包含20个相同的等边三角形面,30个边和12个顶点。
查找二十面体的面积和体积的公式:让a为二十面体的边,然后
Surface area of Icosahedron =
and, Volume of Icosahedron =
C++
// C++ program to find the Area and
// volume of Icosahedron
#include
using namespace std;
// Function to find area of Icosahedron
float findArea(float a)
{
float area;
// Formula to calculating area
area = 5 * sqrt(3) * a * a;
return area;
}
// Function to find volume of Icosahedron
float findVolume(float a)
{
float volume;
// Formula to calculating volume
volume = ((float)5 / 12) * (3 + sqrt(5)) * a * a * a;
return volume;
}
// Driver Code
int main()
{
float a = 5;
// Function call to find area of Icosahedron.
cout << "Area: " << findArea(a) << endl;
// Function call to find volume of Icosahedron.
cout << "Volume: " << findVolume(a);
return 0;
}
Java
// Java program to find the Area and
// volume of Icosahedron
import java.io.*;
class GFG {
// Function to find area of Icosahedron
static float findArea(float a)
{
float area;
// Formula to calculating area
area = (float)(5 * Math.sqrt(3) * a * a);
return area;
}
// Function to find volume of Icosahedron
static float findVolume(float a)
{
float volume;
// Formula to calculating volume
volume = (float)(((float)5 / 12) * (3 + Math.sqrt(5)) * a * a * a);
return volume;
}
// Driver code
public static void main (String[] args)
{
float a = 5;
// Function call to find area of Icosahedron.
System.out.println("Area: " + findArea(a));
// Function call to find volume of Icosahedron.
System.out.println("Volume: " + findVolume(a));
}
}
Python3
# Python3 program to
# find the Area and
# volume of Icosahedron
# import math module
# to use sqrt function
from math import sqrt
# Function to find
# area of Icosahedron
def findArea(a):
# Formula to calculate area
area = 5 * sqrt(3) * a * a
return area
# Function to find
# volume of Icosahedron
def findVolume(a):
# Formula to calculate volume
volume = ((5 / 12) *
(3 + sqrt(5)) *
a * a * a)
return volume
# Driver Code
a = 5
# Function call to
# find area of Icosahedron.
print("Area: " , findArea(a))
# Function call to find
# volume of Icosahedron.
print("Volume: " , findVolume(a))
# This code is contributed
# by ihritik
C#
// C# program to find the Area and
// volume of Icosahedron
using System;
public class GFG {
// Function to find area of Icosahedron
static float findArea(float a)
{
float area;
// Formula to calculating area
area = (float)(5 * Math.Sqrt(3) * a * a);
return area;
}
// Function to find volume of Icosahedron
static float findVolume(float a)
{
float volume;
// Formula to calculating volume
volume = (float)(((float)5 / 12) * (3 + Math.Sqrt(5)) * a * a * a);
return volume;
}
// Driver code
static public void Main ()
{
float a = 5;
// Function call to find area of Icosahedron.
Console.WriteLine("Area: " + findArea(a));
// Function call to find volume of Icosahedron.
Console.WriteLine("Volume: " + findVolume(a));
//Code
}
}
PHP
Javascript
输出:
Area: 216.506
Volume: 272.712