📌  相关文章
📜  内接于等边三角形的圆内接正方形的面积

📅  最后修改于: 2021-10-23 08:11:55             🧑  作者: Mango

这里给出的是一个边长为a的等边三角形,它内切一个圆,它又内切一个正方形。任务是找到这个正方形的面积。
例子:

Input: a = 6
Output: 1

Input: a = 10
Output: 0.527046

方法

下面是上述方法的实现:

C++
// C++ Program to find the area of the square
// inscribed within the circle which in turn
// is inscribed in an equilateral triangle
#include 
using namespace std;
 
// Function to find the area of the square
float area(float a)
{
 
    // a cannot be negative
    if (a < 0)
        return -1;
 
    // area of the square
    float area = sqrt(a) / 6;
 
    return area;
}
 
// Driver code
int main()
{
    float a = 10;
    cout << area(a) << endl;
    return 0;
}


Java
// Java Program to find the area of the square
// inscribed within the circle which in turn
// is inscribed in an equilateral triangle
 
import java.io.*;
 
class GFG {
    
 
// Function to find the area of the square
static float area(float a)
{
 
    // a cannot be negative
    if (a < 0)
        return -1;
 
    // area of the square
    float area = (float)Math.sqrt(a) / 6;
 
    return area;
}
 
// Driver code
    public static void main (String[] args) {
        float a = 10;
    System.out.println( area(a));
// This code is contributed
// by  inder_verma..
    }
}


Python 3
# Python3 Program to find the area
# of the square inscribed within 
# the circle which in turn is
# inscribed in an equilateral triangle
 
# import everything from math lib.
from math import *
 
# Function to find the area
# of the square
def area(a):
 
    # a cannot be negative
    if a < 0 :
        return -1
 
    # area of the square
    area = sqrt(a) / 6
 
    return area
 
# Driver code    
if __name__ == "__main__" :
 
    a = 10
    print(round(area(a), 6))
 
# This code is contributed by ANKITRAI1


C#
// C# Program to find the area
// of the square inscribed within
// the circle which in turn is
// inscribed in an equilateral triangle
using System;
 
class GFG
{
     
// Function to find the area
// of the square
static float area(float a)
{
 
    // a cannot be negative
    if (a < 0)
        return -1;
 
    // area of the square
    float area = (float)Math.Sqrt(a) / 6;
 
    return area;
}
 
// Driver code
public static void Main ()
{
    float a = 10;
    Console.WriteLine(area(a));
}
}
 
// This code is contributed
// by inder_verma


PHP


Javascript


输出:
0.527046

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