📜  从给定的角度和边长找到菱形的区域

📅  最后修改于: 2021-05-06 18:48:12             🧑  作者: Mango

给定两个整数AX ,分别表示菱形边的长度和角度,任务是找到菱形的面积。

例子:

方法:对于具有一个侧的长度和角度X菱形ABCD中,可以使用三角形的侧面角边属性由以下等式来计算三角形ABD的面积:

下面是上述方法的实现:

C++
// C++ Program to calculate
// area of rhombus from given
// angle and side length
#include 
using namespace std;
 
#define RADIAN 0.01745329252
// Function to return the area of rhombus
// using one angle and side.
float Area_of_Rhombus(int a, int theta)
{
    float area = (a * a) * sin((RADIAN * theta));
    return area;
}
 
// Driver Code
int main()
{
    int a = 4;
    int theta = 60;
 
    // Function Call
    float ans = Area_of_Rhombus(a, theta);
 
    // Print the final answer
    printf("%0.2f", ans);
    return 0;
}
 
// This code is contributed by Rajput-Ji


Java
// Java Program to calculate
// area of rhombus from given
// angle and side length
class GFG{
 
static final double RADIAN = 0.01745329252;
   
// Function to return the area of rhombus
// using one angle and side.
static double Area_of_Rhombus(int a, int theta)
{
    double area = (a * a) * Math.sin((RADIAN * theta));
    return area;
}
 
// Driver Code
public static void main(String[] args)
{
    int a = 4;
    int theta = 60;
 
    // Function Call
    double ans = Area_of_Rhombus(a, theta);
 
    // Print the final answer
    System.out.printf("%.2f", ans);
}
}
 
// This code is contributed by Rajput-Ji


Python3
# Python3 Program to calculate
# area of rhombus from given
# angle and side length
   
import math 
   
# Function to return the area of rhombus
# using one angle and side. 
def Area_of_Rhombus(a, theta): 
   
    area = (a**2) * math.sin(math.radians(theta))
   
    return area 
   
# Driver Code 
a = 4
theta = 60
   
# Function Call 
ans = Area_of_Rhombus(a, theta) 
   
# Print the final answer
print(round(ans, 2))


C#
// C# Program to calculate
// area of rhombus from given
// angle and side length
using System;
class GFG{
 
static readonly double RADIAN = 0.01745329252;
   
// Function to return the area of rhombus
// using one angle and side.
static double Area_of_Rhombus(int a, int theta)
{
    double area = (a * a) * Math.Sin((RADIAN * theta));
    return area;
}
 
// Driver Code
public static void Main(String[] args)
{
    int a = 4;
    int theta = 60;
 
    // Function Call
    double ans = Area_of_Rhombus(a, theta);
 
    // Print the readonly answer
    Console.Write("{0:F2}", ans);
}
}
 
// This code is contributed by Rajput-Ji


Javascript


输出:
13.86

时间复杂度: O(1)
辅助空间: O(1)