📜  正方形内一片叶子的面积

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

给定一个整数a作为正方形 ABCD 的边。任务是在正方形内找到叶子AECFA的面积,如下所示:

例子:

方法:计算叶面积,首先求半叶面积AECA,可表示为:

下面是上述方法的实现:

C
// C program to find the area of
// leaf inside a square
#include 
#define PI 3.14159265
 
// Function to find area of
// leaf
float area_leaf(float a)
{
    return (a * a * (PI / 2 - 1));
}
 
// Driver code
int main()
{
    float a = 7;
    printf("%f",
           area_leaf(a));
    return 0;
}


Java
// Java code to find the area of
// leaf inside a square
import java.lang.*;
 
class GFG {
 
    static double PI = 3.14159265;
 
    // Function to find the area of
    // leaf
    public static double area_leaf(double a)
    {
        return (a * a * (PI / 2 - 1));
    }
 
    // Driver code
    public static void main(String[] args)
    {
        double a = 7;
        System.out.println(area_leaf(a));
    }
}


Python3
# Python3 code to find the area of leaf
# inside a square
PI = 3.14159265
     
# Function to find the area of
# leaf
def area_leaf( a ):
    return ( a * a * ( PI / 2 - 1 ) )
     
# Driver code
a = 7
print(area_leaf( a ))


C#
// C# code to find the area of
// leaf
// inside square
using System;
 
class GFG {
    static double PI = 3.14159265;
 
    // Function to find the area of
    // leaf
    public static double area_leaf(double a)
    {
        return (a * a * (PI / 2 - 1));
    }
 
    // Driver code
    public static void Main()
    {
        double a = 7;
        Console.Write(area_leaf(a));
    }
}


PHP


Javascript


输出:
28

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