📜  给定小圆的半径和面积差,求大圆的面积

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

给定两个整数rd ,其中r是较小圆的半径, d是该圆与某个较大半径圆的面积之差。任务是找到较大圆的面积。
例子:

方法:设较小圆和较大圆的半径分别为rR ,面积差为dPI * R 2 – PI * r 2 = d其中PI = 3.14
或者, R 2 = (d / PI) + r 2
现在,大圆的面积可以计算为PI * R 2
下面是上述方法的实现:

C++
// C++ implementation of the approach
#include 
using namespace std;
 
const double PI = 3.14;
 
// Function to return the area
// of the bigger circle
double find_area(int r, int d)
{
    // Find the radius of
    // the bigger circle
    double R = d / PI;
    R += pow(r, 2);
    R = sqrt(R);
 
    // Calculate the area of
    // the bigger circle
    double area = PI * pow(R, 2);
    return area;
}
 
// Driver code
int main()
{
    int r = 4, d = 5;
 
    cout << find_area(r, d);
 
    return 0;
}


Java
// Java implementation of the approach
class GFG
{
    static double PI = 3.14;
 
    // Function to return the area
    // of the bigger circle
    static double find_area(int r, int d)
    {
        // Find the radius of
        // the bigger circle
        double R = d / PI;
        R += Math.pow(r, 2);
        R = Math.sqrt(R);
 
        // Calculate the area of
        // the bigger circle
        double area = PI * Math.pow(R, 2);
        return area;
    }
 
    // Driver code
    public static void main(String[] args)
    {
        int r = 4, d = 5;
 
        System.out.println(find_area(r, d));
    }
}
 
// This code is contributed by PrinciRaj1992


Python3
# Python 3 implementation of the approach
PI = 3.14
from math import pow, sqrt
 
# Function to return the area
# of the bigger circle
def find_area(r, d):
     
    # Find the radius of
    # the bigger circle
    R = d / PI
    R += pow(r, 2)
    R = sqrt(R)
 
    # Calculate the area of
    # the bigger circle
    area = PI * pow(R, 2)
    return area
 
# Driver code
if __name__ == '__main__':
    r = 4
    d = 5
 
    print(find_area(r, d))
 
# This code is contributed by
# Surendra_Gangwar


C#
// C# implementation of the approach
using System;
 
public class GFG
{
    static double PI = 3.14;
 
    // Function to return the area
    // of the bigger circle
    static double find_area(int r, int d)
    {
        // Find the radius of
        // the bigger circle
        double R = d / PI;
        R += Math.Pow(r, 2);
        R = Math.Sqrt(R);
 
        // Calculate the area of
        // the bigger circle
        double area = PI * Math.Pow(R, 2);
        return area;
    }
 
    // Driver code
    static public void Main ()
    {
     
        int r = 4, d = 5;
        Console.Write(find_area(r, d));
    }
}
 
// This code is contributed by ajit.


PHP


Javascript


输出:
55.24