给定一个椭圆,长轴和短轴长度分别为 2a 和 2b。任务是找到可以内切的最大圆的面积。
例子:
Input : a = 5, b = 3
Output : 28.2743
Input : a = 10, b = 8
Output : 201.062
方法:内接于椭圆的圆的最大半径为椭圆的短轴。
所以,最大圆的面积 = π * b * b 。
下面是上述方法的实现:
C++
// CPP program to find
// the area of the circle
#include
using namespace std;
#define pi 3.1415926
double areaCircle(double b)
{
double area = pi * b * b;
return area;
}
// Driver Code
int main()
{
double a = 10, b = 8;
cout << areaCircle(b);
return 0;
}
Java
// Java Program to find the area
// of circle
class GFG
{
static double areaCircle(double b)
{
// Area of the Reuleaux triangle
double area = (double)3.1415926 * b * b;
return area;
}
// Driver code
public static void main(String args[])
{
float a = 10,b = 8;
System.out.println(areaCircle(b)) ;
}
}
// This code is contributed by mohit kumar 29
Python3
# Python3 program implementation of above approach
import math
# Function to return required answer
def areaCircle(b):
area = math.pi * b * b
return area
# Driver Code
a = 10
b = 8
print(areaCircle(b))
# This code is contributed by
# Sanjit_Prasad
C#
// C# Program to find the area
// of circle
using System;
class GFG
{
static double areaCircle(double b)
{
// Area of the Reuleaux triangle
double area = (double)3.1415926 * b * b;
return area;
}
// Driver code
public static void Main()
{
float b = 8;
Console.WriteLine(areaCircle(b)) ;
}
}
// This code is contributed by aishwarya.27
PHP
Javascript
输出:
201.062
如果您希望与专家一起参加现场课程,请参阅DSA 现场工作专业课程和学生竞争性编程现场课程。