📜  计算等边三角形的圆周面积的程序

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

给定一个等边三角形的边长。我们需要编写一个程序来计算给定等边三角形的 Circumcircle 的面积。
例子:

Input : side = 6
Output : Area of circumscribed circle is: 37.69

Input : side = 9
Output : Area of circumscribed circle is: 84.82 

等边三角形的三个边长相等,三个内角都是60度。
圆的性质如下:

  • 外接圆的中心是等边三角形的中线相交的点。
  • 等边三角形的外接圆是通过等边三角形的三个顶点构成的。
  • 等边三角形外接圆的半径等于(a / √3),其中’a’是等边三角形边长。

下图显示了一个带外接圆的等边三角形:

外接圆面积的计算公式为:

(π*a2)/3

其中a是给定等边三角形的边长。

这个公式是如何工作的?

我们知道圆的面积 = π*r 2 ,其中 r 是给定圆的半径。
我们也知道等边三角形的圆周半径=(等边三角形的边)/√3。
因此,面积 = π*r 2 = π*a 2 /3。

C++
// C++ program to find the area of Cicumscribed
// circle of equilateral triangle
#include 
#include 
const double pi = 3.14159265358979323846;
 
using namespace std;
 
// function to calculate the area of circumcircle
// of equilateral triangle
float area_circumscribed(float a)
{
    return (a * a * (pi / 3));
}
// Driver code
int main()
{
    float a, Area;
    a = 6;
 
    // function calling
    Area = area_circumscribed(a);
    // displaying the area
    cout << "Area of CircumCircle :" << Area;
    return 0;
}


C
// C program to find the area of Cicumscribed
// circle of equilateral triangle
#include 
#define PI 3.14159265
 
// function to find area of
// circumscribed circle
float area_circumscribed(float a)
{
    return (a * a * (PI / 3));
}
 
// Driver code
int main()
{
    float a = 6;
    printf("Area of circumscribed circle is :%f",
            area_circumscribed(a));
    return 0;
}


Java
// Java code to find the area of circumscribed
// circle of equilateral triangle
import java.lang.*;
 
class GFG {
     
    static double PI = 3.14159265;
     
    // function to find the area of
    // circumscribed circle
    public static double area_cicumscribed(double a)
    {
        return (a * a * (PI / 3));
    }
     
    // Driver code
    public static void main(String[] args)
    {
        double a = 6.0;
        System.out.println("Area of circumscribed circle is :"
                            + area_cicumscribed(a));
    }
}


Python3
# Python3 code to find the area of circumscribed
# circle of equilateral triangle
PI = 3.14159265
     
# Function to find the area of
# circumscribed circle
def area_cicumscribed(a):
    return (a * a * (PI / 3))
     
# Driver code
a = 6.0
print("Area of circumscribed circle is :%f"
                        %area_cicumscribed(a))
 
# This code is contributed by Anant Agarwal.


C#
// C# code to find the area of
// circumscribed circle
// of equilateral triangle
using System;
 
class GFG {
    static double PI = 3.14159265;
     
    // function to find the area of
    // circumscribed circle
    public static double area_cicumscribed(double a)
    {
        return (a * a * (PI / 3));
    }
     
    // Driver code
    public static void Main()
    {
        double a = 6.0;
        Console.Write("Area of circumscribed circle is :" +
                       area_cicumscribed(a));
    }
}
 
// This code is contributed by nitin mittal.


PHP


Javascript


输出:
Area of circumscribed circle is :37.6991118