📜  绳子的长度绑在彼此接触的三个相等的圆周上

📅  最后修改于: 2021-04-29 01:37:26             🧑  作者: Mango

给定r是彼此接触的三个相等圆的半径。任务是找到绑在圆圈上的绳索的长度,如下所示:

例子:

方法:从上图可以清楚地看到,不与圆接触的绳索的长度部分为2r + 2r + 2r = 6r
绳索接触圆圈的部分在每个圆圈上形成120度的扇形。因此,每个120度的三个扇区可以视为完整的360度的一圈。
因此,绳索接触圆的长度为2 * PI * r ,其中PI = 22/7r为圆的半径。
因此,绳索的总长度将为(2 * PI * r)+ 6r

下面是上述方法的实现:

CPP
// C++ program to find the length
// of rope
#include
using namespace std;
#define PI 3.14159265
  
// Function to find the length
// of rope
float length_rope( float r )
{
    return ( ( 2 * PI * r ) + 6 * r );
}
  
// Driver code
int main()
{
    float r = 7;
    cout<


C
// C program to find the length
// of rope
#include 
#define PI 3.14159265
  
// Function to find the length
// of rope
float length_rope( float r )
{
    return ( ( 2 * PI * r ) + 6 * r );
}
  
// Driver code
int main()
{
    float r = 7;
    printf("%f",
           length_rope( r ));
    return 0;
}


Java
// Java code to find the length
// of rope
import java.lang.*;
  
class GFG {
  
    static double PI = 3.14159265;
  
    // Function to find the length
    // of rope
    public static double length_rope(double r)
    {
        return ((2 * PI * r) + 6 * r);
    }
  
    // Driver code
    public static void main(String[] args)
    {
        double r = 7;
        System.out.println(length_rope(r));
    }
}


Python3
# Python3 code to find the length
# of rope
PI = 3.14159265
      
# Function to find the length
# of rope
def length_rope( r ):
    return ( ( 2 * PI * r ) + 6 * r )
      
# Driver code
r = 7
print( length_rope( r ))


C#
// C# code to find the length
// of rope
using System;
  
class GFG {
    static double PI = 3.14159265;
  
    // Function to find the length
    // of rope
    public static double length_rope(double r)
    {
        return ((2 * PI * r) + 6 * r);
    }
  
    // Driver code
    public static void Main()
    {
        double r = 7.0;
        Console.Write(length_rope(r));
    }
}


PHP


输出:
86