Dados los lados del octaedro, calcule el área de la superficie.
Ejemplos:
Input : 7 Output : 169.741 Input : 9 Output : 280.59
Un octaedro regular tiene ocho caras, todas en forma de triángulos equiláteros. El área de un octaedro es 2 multiplicado por la longitud de una arista al cuadrado multiplicado por la raíz cuadrada de tres.
Fórmula:
área de superficie = 2*(sqrt(3))*(lado*lado)
C++
// CPP Program to calculate // surface area of Octahedron #include <bits/stdc++.h> 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
<?php // PHP Program to calculate // surface area of Octahedron // utility Function function surface_area_octahedron($side) { return (2 * (sqrt(3)) * ($side * $side)); } // Driver Code $side = 7; echo("Surface area of octahedron ="); echo( surface_area_octahedron($side)); // This code is contributed by vt_m. ?>
Javascript
<script> // JavaScript program to calculate // surface area of Octahedron. // Utility Function function surface_area_octahedron(side) { return (2 * (Math.sqrt(3)) * (side*side)); } // Driver Code let side = 7; document.write("Surface area of octahedron =" + surface_area_octahedron(side)); // This code is contributed by avijitmondal1998 </script>
Producción:
Surface area of octahedron =169.741
Complejidad temporal : O(1)
Espacio auxiliar : O(1)
Publicación traducida automáticamente
Artículo escrito por azkia anam y traducido por Barcelona Geeks. The original can be accessed here. Licence: CCBY-SA