Dado que aquí hay un triángulo equilátero con lado de longitud a, la tarea es encontrar el área del círculo inscrito en ese triángulo equilátero.
Ejemplos:
Input : a = 4 Output : 4.1887902047863905 Input : a = 10 Output : 26.1799387799
Acercarse:
Área del triángulo equilátero =
Semiperímetro del triángulo equilátero = (a + a + a) / 2
Radio del círculo inscrito r = Área del triángulo equilátero / Semiperímetro del triángulo equilátero
=
=
Área del círculo = PI*(r*r) =*** QuickLaTeX no puede compilar la fórmula: *** Mensaje de error: Error: nada que mostrar, la fórmula está vacía
A continuación se muestra la implementación del enfoque anterior:
C++
// C++ program to find the area // of circle which is inscribed // in equilateral triangle # include<bits/stdc++.h> # define PI 3.14 using namespace std; // Function return the area of circle // inscribed in equilateral triangle float circle_inscribed(int a) { return PI * (a * a) / 12; } // Driver code int main() { int a = 4; cout << circle_inscribed(a); return 0; } // This code is contributed // by Mahadev99
Java
// Java program to find the area // of circle which is inscribed // in equilateral triangle import java.io.*; class GFG { static double PI = 3.14; // Function return the area of circle // inscribed in equilateral triangle static double circle_inscribed(int a) { return PI * (a * a) / 12; } // Driver code public static void main (String[] args) { int a = 4; System.out.println(circle_inscribed(a)); } } // This code is contributed by anuj_67
Python3
# Python3 program to find the area of circle # which is inscribed in equilateral triangle # import math library for pi value from math import pi # Function return the area of circle # inscribed in equilateral triangle def circle_inscribed(a): return pi*(a * a) / 12 # Driver code a = 4 print(circle_inscribed(a))
C#
// C# program to find the area // of circle which is inscribed // in equilateral triangle using System; class GFG { static double PI = 3.14; // Function return the area of circle // inscribed in equilateral triangle static double circle_inscribed(int a) { return PI * (a * a) / 12; } // Driver code public static void Main () { int a = 4; Console.WriteLine( circle_inscribed(a)); } } // This code is contributed // by inder_verma
PHP
<?php // PHP program to find the area // of circle which is inscribed // in equilateral triangle // Function return the area of circle // inscribed in equilateral triangle function circle_inscribed($a) { return 3.14 * ($a * $a) / 12; } // Driver code $a = 4; echo circle_inscribed($a); // This code is contributed // by Akanksha Rai(Abby_akku)
Javascript
<script> // javascript program to find the area // of circle which is inscribed // in equilateral triangle let PI = 3.14; // Function return the area of circle // inscribed in equilateral triangle function circle_inscribed( a) { return PI * (a * a) / 12; } // Driver code let a = 4; document.write(circle_inscribed(a).toFixed(5)); // This code contributed by gauravrajput1 </script>
Producción:
4.1887902047863905
Complejidad del tiempo :O(1)
complejidad del espacio: O(1)
Publicación traducida automáticamente
Artículo escrito por shrikanth13 y traducido por Barcelona Geeks. The original can be accessed here. Licence: CCBY-SA