给定一个圆的两个相等长度的弦以及中心和一个弦之间的距离。这里的任务是找到中心和另一个和弦之间的距离。
例子:
Input: 48
Output: 48
Input: 82
Output: 82
下面是上述方法的实现:
方法:
设AB和CD是圆心在O的两个相等的弦。 OM是弦AB到中心的给定距离。
现在在三角形AOM和CON 中,
OA = OC (同圆的半径)
MA = CN (因为 OM 和 ON 垂直于弦并且它平分弦并且 AM = MB & CN = CD)
角度AMO = 角度ONC = 90 度
所以三角形是全等的
所以, OM = ON
Equal chords of a circle are equidistant from the centre of a circle.
下面是上述方法的实现:
C++
// C++ program to find the distance of chord
// from center when distance between center
// and another equal length chord is given
#include
using namespace std;
void lengequichord(int z)
{
cout << "The distance between the "
<< "chord and the center is "
<< z << endl;
}
// Driver code
int main()
{
int z = 48;
lengequichord(z);
return 0;
}
Java
// Java program to find the distance of chord
// from center when distance between center
// and another equal length chord is given/
import java.io.*;
class GFG
{
static void lengequichord(int z)
{
System.out.println ("The distance between the "+
"chord and the center is "+ z );
}
// Driver code
public static void main (String[] args)
{
int z = 48;
lengequichord(z);
}
}
// This code is contributed by jit_t.
Python 3
# Python 3 program to find the distance of chord
# from center when distance between center
# and another equal length chord is given
def lengequichord(z):
print("The distance between the" ,
"chord and the center is" , z )
# Driver code
if __name__ == "__main__":
z = 48
lengequichord(z)
# This code is contributed
# by ChitraNayal
C#
// C# program to find the distance of chord
// from center when distance between center
// and another equal length chord is given
using System;
class GFG
{
static void lengequichord(int z)
{
Console.WriteLine("The distance between the "+
"chord and the center is "+ z );
}
// Driver code
public static void Main ()
{
int z = 48;
lengequichord(z);
}
}
// This code is contributed by AnkitRai01
Javascript
输出:
The distance between the chord and the center is 48
如果您希望与专家一起参加现场课程,请参阅DSA 现场工作专业课程和学生竞争性编程现场课程。