📜  八面体表面积程序

📅  最后修改于: 2021-10-23 08:29:11             🧑  作者: Mango

给定八面体的边,然后计算表面积。

例子:

Input  : 7
Output : 169.741

Input  : 9
Output : 280.59

正八面体有八个面,都是等边三角形的形状。八面体的面积是2乘以边长的平方乘以三的平方根。

C++
// CPP Program to calculate
// surface area of Octahedron
#include 
using namespace std;
 
// utility Function
double surface_area_octahedron(double side)
{
    return (2*(sqrt(3))*(side*side));
}
 
// Driver Function
int main()
{
    double side = 7;
    cout << "Surface area of octahedron ="
        << surface_area_octahedron(side)
        << endl;
}


Java
// Java Program to calculate
// surface area of Octahedron.
 
import java.io.*;
import java.util.*;
 
class GFG {
     
// utility Function
static double surface_area_octahedron(double side)
{
    return (2*(Math.sqrt(3))*(side*side));
}
    public static void main (String[] args) {
    double side = 7;
    System.out.println("Surface area of octahedron ="
                    + surface_area_octahedron(side));
     
    }
}
 
// This code is contributed by Gitanjali.


Python3
# Python Program to calculate
# surface area of Octahedron.
import math
 
# utility Function
def surface_area_octahedron( side):
 
    return (2*(math.sqrt(3))*(side*side))
 
# driver code
side = 7
print("Surface area of octahedron =" ,
      surface_area_octahedron(side))
 
# This code is contributed by Gitanjali.


C#
// C# program to calculate
// surface area of Octahedron.
using System;
 
class GFG {
 
    // utility Function
    static double surface_area_octahedron(double side)
    {
        return (2 * (Math.Sqrt(3)) * (side * side));
    }
     
    // Driver code
    public static void Main()
    {
        double side = 7;
        Console.WriteLine("Surface area of octahedron ="
                        + surface_area_octahedron(side));
    }
}
 
// This code is contributed by vt_m.


PHP


Javascript


输出:

Surface area of octahedron =169.741