📜  直角三角形的内圆面积

📅  最后修改于: 2021-10-23 09:06:30             🧑  作者: Mango

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

例子:

方法:计算直角三角形半径的公式可以表示为r = ( P + B – H ) / 2
我们知道圆的面积是PI * r 2其中PI = 22 / 7并且r是圆的半径。
因此,内圆的面积将是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

如果您希望与专家一起参加现场课程,请参阅DSA 现场工作专业课程学生竞争性编程现场课程