Dada la P, B y H son la perpendicular, la base y la hipotenusa respectivamente de un triángulo rectángulo. La tarea es encontrar el área del incírculo de radio r como se muestra a continuación:
Ejemplos:
Entrada: P = 3, B = 4, H = 5
Salida: 3,14
Entrada: P = 5, B = 12, H = 13
Salida: 12,56
Enfoque: la fórmula para calcular el radio interior de un triángulo rectángulo se puede dar como r = ( P + B – H ) / 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 incírculo será PI * ((P + B – H) / 2) 2 .
A continuación se muestra la implementación del enfoque anterior:
C++
// C++ program to find the area of // incircle of right angled triangle #include <bits/stdc++.h> using namespace std; #define PI 3.14159265 // Function to find area of // incircle float area_inscribed(float P, float B, float H) { return ((P + B - H) * (P + B - H) * (PI / 4)); } // Driver code int main() { float P = 3, B = 4, H = 5; cout << area_inscribed(P, B, H) << endl; return 0; } // The code is contributed by Nidhi goel
C
// C program to find the area of // incircle of right angled triangle #include <stdio.h> #define PI 3.14159265 // Function to find area of // incircle float area_inscribed(float P, float B, float H) { return ((P + B - H) * (P + B - H) * (PI / 4)); } // Driver code int main() { float P = 3, B = 4, H = 5; printf("%f", area_inscribed(P, B, H)); return 0; }
Java
// Java code to find the area of inscribed // circle of right angled triangle import java.lang.*; class GFG { static double PI = 3.14159265; // Function to find the area of // inscribed circle public static double area_inscribed(double P, double B, double H) { return ((P + B - H) * (P + B - H) * (PI / 4)); } // Driver code public static void main(String[] args) { double P = 3, B = 4, H = 5; System.out.println(area_inscribed(P, B, H)); } }
Python3
# Python3 code to find the area of inscribed # circle of right angled triangle PI = 3.14159265 # Function to find the area of # inscribed circle def area_inscribed(P, B, H): return ((P + B - H)*(P + B - H)*(PI / 4)) # Driver code P = 3 B = 4 H = 5 print(area_inscribed(P, B, H))
C#
// C# code to find the area of // inscribed circle // of right angled triangle using System; class GFG { static double PI = 3.14159265; // Function to find the area of // inscribed circle public static double area_inscribed(double P, double B, double H) { return ((P + B - H) * (P + B - H) * (PI / 4)); } // Driver code public static void Main() { double P = 3.0, B = 4.0, H = 5.0; Console.Write(area_inscribed(P, B, H)); } }
PHP
<?php // PHP program to find the // area of inscribed // circle of right angled triangle $PI = 3.14159265; // Function to find area of // inscribed circle function area_inscribed($P, $B, $H) { global $PI; return (($P + $B - $H)*($P + $B - $H)* ($PI / 4)); } // Driver code $P=3; $B=4; $H=5; echo(area_inscribed($P, $B, $H)); ?>
Javascript
<script> // javascript code to find the area of inscribed // circle of right angled triangle let PI = 3.14159265; // Function to find the area of // inscribed circle function area_inscribed(P , B , H) { return ((P + B - H) * (P + B - H) * (PI / 4)); } // Driver code var P = 3, B = 4, H = 5; document.write(area_inscribed(P, B, H).toFixed(6)); // This code is contributed by Rajput-Ji </script>
Producción:
3.141593
Complejidad de tiempo : O(1)
Espacio Auxiliar: O(1)