📜  程序来计算刻在正方形上的圆的面积

📅  最后修改于: 2021-04-23 22:02:55             🧑  作者: Mango

给定正方形的一面。任务是找到正方形内切圆的面积。

例子:

Input : a = 8
Output : Area of an inscribed circle: 50.24

Input : a = 12.04
Output : Area of an inscribed circle: 113.795

给定一个正方形,即正方形的所有边均等长,并且所有四个角度均为90度。下图描绘了正方形中的内接圆。

内接圆

正方形中的内接圆的属性:

  • 正方形内切圆的直径等于正方形边的长度。
  • 通过至少一个对圆或正方形的度量,可以计算出内切圆的正方形的面积和周长。
  • 正方形的中心和圆的中心在同一点。
  • 当至少给出一个圆或正方形的度量时,可以计算出圆的周长和面积。
    C++
    // C++ Program to find the area of 
    // an inscribed circle in a square.
    #include
    #define PI 3.14
    using namespace std;
      
    // Function to find area of an 
    // inscribed circle in a square.
    float areaOfInscribedCircle(float a)
    {
        return ( PI / 4 ) * a * a;
    }
      
    // Driver's code
    int main()
    {
        float a = 8;
          
        cout << "Area of an inscribed circle: "
             << areaOfInscribedCircle(a);
               
        return 0;
    }


    Java
    // Java Program to find the area of 
    // an inscribed circle in a square.
    import java.io.*;
      
    class GFG {
          
        static double PI = 3.14;
          
        // Function to find area of an 
        // inscribed circle in a square.
        static double areaOfInscribedCircle(float a)
        {
            return ( PI / 4 ) * a * a;
        }
      
        // Driver code
        public static void main (String[] args)
        {
            float a = 8;
          
            System.out.println("Area of an inscribed"
            + " circle: " + areaOfInscribedCircle(a));
        }
    }


    Python 3
    # Python Program to find the area of 
    # an inscribed circle in a square.
          
    PI = 3.14
          
    # Function to find area of an 
    # inscribed circle in a square.
    def areaOfInscribedCircle(a):
        return ( PI / 4 ) * a * a
      
    # Driver code
    a = 8
    print("Area of an inscribed circle:",
      round(areaOfInscribedCircle(a), 2))


    C#
    // C# Program to find the 
    // area of an inscribed 
    // circle in a square.
    using System;
      
    class GFG 
    {
        static double PI = 3.14;
          
        // Function to find area  
        // of an inscribed circle
        // in a square.
        static double areaOfInscribedCircle(float a)
        {
            return (PI / 4 ) * a * a;
        }
      
        // Driver code
        public static void Main ()
        {
            float a = 8;
          
            Console.WriteLine("Area of an inscribed" + 
                                         " circle: " +
                            areaOfInscribedCircle(a));
        }
    }
      
    // This code is contributed
    // by anuj_6


    PHP


    输出:
    Area of an inscribed circle:50.24