📜  程序查找四边形的角度

📅  最后修改于: 2021-06-27 00:01:35             🧑  作者: Mango

假设四边形的所有角度都在AP中且具有共同的差’d’,则任务是找到所有角度。
例子:

Input: d = 10
Output: 75, 85, 95, 105

Input: d = 20
Output: 60, 80, 100, 120

方法:

下面是上述方法的实现:

C++
// C++ implementation of the approach
#include 
#define ll long long int
using namespace std;
 
// Driver code
int main()
{
    int d = 10;
    double a;
 
    // according to formula derived above
    a = (double)(360 - (6 * d)) / 4;
 
    // print all the angles
    cout << a << ", " << a + d << ", " << a + (2 * d)
         << ", " << a + (3 * d) << endl;
    return 0;
}


Java
// java implementation of the approach
 
import java.io.*;
 
class GFG {
  
// Driver code
 
    public static void main (String[] args) {
            int d = 10;
    double a;
 
    // according to formula derived above
    a = (double)(360 - (6 * d)) / 4;
 
    // print all the angles
    System.out.print( a + ", " + (a + d) + ", " + (a + (2 * d))
        + ", " + (a + (3 * d)));
    }
}
//This code is contributed
//by  inder_verma


Python
# Python implementation
# of the approach
d = 10
a = 0.0
 
# according to formula
# derived above
a=(360 - (6 * d)) / 4
 
# print all the angles
print(a,",", a + d, ",", a + 2 * d,
        ",", a + 3 * d, sep = ' ')
 
# This code is contributed
# by sahilshelangia


C#
// C# implementation of the approach
using System;
 
class GFG
{
 
// Driver code
public static void Main ()
{
    int d = 10;
    double a;
     
    // according to formula derived above
    a = (double)(360 - (6 * d)) / 4;
     
    // print all the angles
    Console.WriteLine( a + ", " + (a + d) +
                           ", " + (a + (2 * d)) +
                           ", " + (a + (3 * d)));
}
}
 
// This code is contributed
// by anuj_67


PHP


Javascript


输出:
75, 85, 95, 105