Dado un entero C que es la longitud de la hipotenusa de un triángulo rectángulo de un círculo que pasa por el centro del círculo. La tarea es encontrar el área del circuncírculo.
Ejemplos:
Entrada: C = 8
Salida: 50,26
Entrada: C = 10
Salida: 78,53
Aproximación: Dado que la hipotenusa C pasa por el centro de la circunferencia, el radio de la circunferencia será C/ 2 .
Y sabemos que el área de un círculo es PI * r 2 donde PI = 22/7 y r es el radio del círculo.
Por lo tanto, el área del círculo circunscrito será PI * (C/2) 2 , es decir , PI * C 2/4 .
A continuación se muestra la implementación del enfoque anterior:
C++
// C++ program to find the area of Circumscribed // circle of right angled triangle #include <bits/stdc++.h> #define PI 3.14159265 using namespace std; // Function to find area of // circumscribed circle float area_circumscribed(float c) { return (c * c * (PI / 4)); } // Driver code int main() { float c = 8; cout << area_circumscribed(c); return 0; } // This code is contributed by Shivi_Aggarwal
C
// C program to find the area of Circumscribed // circle of right angled triangle #include <stdio.h> #define PI 3.14159265 // Function to find area of // circumscribed circle float area_circumscribed(float c) { return (c * c * (PI / 4)); } // Driver code int main() { float c = 8; printf("%f", area_circumscribed(c)); return 0; }
Java
// Java code to find the area of circumscribed // circle of right angled triangle import java.lang.*; class GFG { static double PI = 3.14159265; // Function to find the area of // circumscribed circle public static double area_cicumscribed(double c) { return (c * c * (PI / 4)); } // Driver code public static void main(String[] args) { double c = 8.0; System.out.println(area_cicumscribed(c)); } }
Python3
# Python3 code to find the area of circumscribed # circle of right angled triangle PI = 3.14159265 # Function to find the area of # circumscribed circle def area_cicumscribed(c): return (c * c * (PI / 4)) # Driver code c = 8.0 print(area_cicumscribed(c))
C#
// C# code to find the area of // circumscribed circle // of right angled triangle using System; class GFG { static double PI = 3.14159265; // Function to find the area of // circumscribed circle public static double area_cicumscribed(double c) { return (c * c * (PI / 4)); } // Driver code public static void Main() { double c = 8.0; Console.Write(area_cicumscribed(c)); } }
PHP
<?php // PHP program to find the // area of Circumscribed // circle of right angled triangle $PI = 3.14159265; // Function to find area of // circumscribed circle function area_circumscribed($c) { global $PI; return ($c * $c * ($PI / 4)); } // Driver code $c = 8; echo(area_circumscribed($c)); ?>
Javascript
<script> // javascript code to find the area of circumscribed // circle of right angled triangle let PI = 3.14159265; // Function to find the area of // circumscribed circle function area_cicumscribed(c) { return (c * c * (PI / 4)); } // Driver code var c = 8.0; document.write(area_cicumscribed(c).toFixed(6)); // This code is contributed by Rajput-Ji </script>
50.265484
Complejidad temporal: O(1), ya que no hay bucle ni recursividad.
Espacio Auxiliar: O(1), ya que no se ha ocupado ningún espacio extra.