📜  鲁洛三角区

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

给定一个整数h ,它是由与鲁洛三角形相同的顶点形成的等边三角形的边,任务是找到并打印鲁洛三角形的面积。

例子:

方法:三个圆ABC相交所形成的形状是鲁洛三角形,同一个顶点所形成的三角形即ABC是一个边为h的等边三角形。

下面是上述方法的实现:

C++
// C++ Program to find the area
// of Reuleaux triangle
#include 
using namespace std;
 
// Function to find the Area
// of the Reuleaux triangle
float ReuleauxArea(float a)
{
 
    // Side cannot be negative
    if (a < 0)
        return -1;
 
    // Area of the Reuleaux triangle
    float A = 0.70477 * pow(a, 2);
    return A;
}
 
// Driver code
int main()
{
    float a = 6;
    cout << ReuleauxArea(a) << endl;
    return 0;
}


Java
// Java Program to find the area
// of Reuleaux triangle
 
public class GFG
{
    // Function to find the Area
    // of the Reuleaux triangle
    static double ReuleauxArea(float a)
    {
     
        // Side cannot be negative
        if (a < 0)
            return -1;
     
        // Area of the Reuleaux triangle
        double A = (double)0.70477 * Math.pow(a, 2);
        return A;
    }
     
    // Driver code
    public static void main(String args[])
    {
        float a = 6;
        System.out.println(ReuleauxArea(a)) ;
    }
    // This code is contributed by Ryuga
}


Python3
# Python3 program to find the area
# of Reuleaux triangle
import math as mt
 
# function to the area of the
# Reuleaux triangle
def ReuleauxArea(a):
     
    # Side cannot be negative
    if a < 0:
        return -1
    # Area of the Reauleax triangle
    return 0.70477 * pow(a, 2)
 
# Driver code
a = 6
print(ReuleauxArea(a))
 
# This code is contributed
# by Mohit Kumar


C#
// C# Program to find the area 
// of Reuleaux triangle 
   
using System;
 
public class GFG
{
    // Function to find the Area 
    // of the Reuleaux triangle 
    static double ReuleauxArea(float a) 
    { 
       
        // Side cannot be negative 
        if (a < 0) 
            return -1; 
       
        // Area of the Reuleaux triangle 
        double A = (double)0.70477 * Math.Pow(a, 2); 
        return A; 
    } 
       
    // Driver code 
    public static void Main() 
    { 
        float a = 6; 
        Console.WriteLine(ReuleauxArea(a)) ; 
    }
}
    // This code is contributed by Subhadeep


PHP


Javascript


输出:
25.3717

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