给定等腰梯形 ABCD 的两个底为a和b ,任务是找到该梯形内切圆的面积
例子:
Input: a = 10, b = 30
Output: Area = 235.57
Input: a = 20, b = 36
Output: Area = 565.38
推导:给定一个圆内切于梯形ABCD(边AB = n,CD = m),我们需要找出梯形的高度,即(AL),它是圆半径的一半,以求出其面积圈子。
为了找到圆的高度,我们执行以下操作。
- 圆总是在它们的中点处接触梯形的边,假设AB,BD,CD,AC的中点是G,F,H,E,并与圆的中心连接。
- 现在从对称性,我们可以看到
AG = AE = n/2,
EC = CG = m/2,
HD = DF = n/2,
GB = FB = m/2
- 现在在三角形 ACL 中应用勾股定理。
Hypotenuse AC = m/2 + n/2
Base CL = CH - AG = m/2 - n/2
we get
Perpendicular AL = Square_root(m * n)
- 因此梯形的高度 = AL = Square_Root(给定边的乘积)
- 现在圆的半径只是高度的一半,因此可以轻松计算面积。
方法:
- 求梯形的高度为(square_root( m * n )) 。
- 求内圆的半径
R = height / 2
= square_root(m * n) / 2
- 现在找到圆的面积
= Pi * R2
= ( 3.141 * m * n ) / 4
下面是上述方法的实现:
C++
// CPP implementation to find
// the rea of the circle
// inscribed in a trapezoid
// having non- parallel sides m, n
#include
using namespace std;
// Function to find area of circle
// inscribed in a trapezoid
// having non- parallel sides m, n
double area_of_circle(int m, int n)
{
// radius of circle by the
// formula i.e. root( m * n) / 2
// area of circle = (3.141 ) * ( R ** 2 )
int square_of_radius = ( m * n ) / 4;
double area = ( 3.141 * square_of_radius );
return area;
}
// Driver Code
int main(){
int n = 10;
int m = 30;
cout << (area_of_circle(m, n));
}
// This code is contributed by mohit kumar 29
Java
// Java Program to find
// the rea of the circle
// inscribed in a trapezoid
// having non- parallel sides m, n
class GFG
{
// Function to find area of circle
// inscribed in a trapezoid
// having non- parallel sides m, n
static double area_of_circle(int m, int n)
{
// radius of circle by the
// formula i.e. root( m * n) / 2
// area of circle = (3.141 ) * ( R ** 2 )
int square_of_radius = ( m * n ) / 4;
double area = ( 3.141 * square_of_radius );
return area;
}
// Driver code
public static void main (String[] args)
{
int n = 10;
int m = 30;
System.out.println(area_of_circle(m, n));
}
}
// This code is contributed by Yash_R
Python3
# Python 3 implementation to find
# the rea of the circle
# inscribed in a trapezoid
# having non- parallel sides m, n
# Function to find area of circle
# inscribed in a trapezoid
# having non- parallel sides m, n
def area_of_circle(m, n):
# radius of circle by the
# formula i.e. root( m * n) / 2
# area of circle = (3.141 ) * ( R ** 2 )
square_of_radius = ( m * n ) / 4
area = ( 3.141 * square_of_radius )
return area
# Driver Code
if __name__=='__main__':
n = 10
m = 30
print(area_of_circle(m, n))
C#
// C# Program to find
// the rea of the circle
// inscribed in a trapezoid
// having non- parallel sides m, n
using System;
class GFG
{
// Function to find area of circle
// inscribed in a trapezoid
// having non- parallel sides m, n
static double area_of_circle(int m, int n)
{
// radius of circle by the
// formula i.e. root( m * n) / 2
// area of circle = (3.141 ) * ( R ** 2 )
int square_of_radius = ( m * n ) / 4;
double area = ( 3.141 * square_of_radius );
return area;
}
// Driver code
public static void Main ()
{
int n = 10;
int m = 30;
Console.WriteLine(area_of_circle(m, n));
}
}
// This code is contributed by Sanjit_Prasad
Javascript
输出:
235.575
如果您希望与专家一起参加现场课程,请参阅DSA 现场工作专业课程和学生竞争性编程现场课程。