📜  直角三角形的内切面积

📅  最后修改于: 2021-04-24 20:32:30             🧑  作者: Mango

给定P,B和H分别是直角三角形的垂直,底边和斜边。任务是找到半径为r的内切圆的面积,如下所示:

例子:

方法:可以计算直角三角形的半径的公式为r =(P + B – H)/ 2
而且我们知道,圆的面积为PI * r 2 ,其中PI = 22/7r为圆的半径。
因此,圆的面积将为PI *((P + B – H)/ 2) 2
下面是上述方法的实现:

C
// C program to find the area of
// incircle of right angled triangle
#include 
#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


Javascript


输出:
3.141593