鉴于度的角度,任务是将其转换成弧度。
例子:
Input: degree = 45
Output: radian = 0.785398
Input: degree = 58
Output: radian = 1.01229
方法:
弧度:弧度是用于测量角度的SI单位,主要用于三角学中。弧度由圆弧定义。一个完整的圆刚好超过6个弧度(大约6.28)。一弧度略低于57.3度。
度:度,通常用°(度符号)表示,是平面角的量度,定义为完整旋转360度。因为完整旋转等于2 * pi弧度,所以一个度等于pi / 180弧度。
将弧度转换为度的公式是:
radian = degree * (pi/180)
where pi = 22/7
下面是上述方法的实现:
C++
// C++ program to convert degree to radian
#include
#include
using namespace std;
// Function for conversion
double Convert(double degree)
{
double pi = 3.14159265359;
return (degree * (pi / 180));
}
// Driver code
int main()
{
double degree = 30;
double radian = Convert(degree);
cout << radian;
return 0;
}
Java
// Java program to convert degree to radian
import java.io.*;
import java.util.*;
class GFG {
// Function for conversion
static double Convert(double degree)
{
double pi = 3.14159265359;
return (degree * (pi / 180));
}
// Driver code
public static void main(String[] args)
{
double degree = 30;
double radian = Convert(degree);
System.out.printf("%.6f", radian);
}
}
// This code is contributed by coder001
Python3
# Python3 program to convert degree to radian
# Function for conversion
def Convert(degree):
pi = 3.14159265359;
return (degree * (pi / 180));
# Driver code
degree = 30;
radian = Convert(degree);
print(radian);
# This code is contributed by Code_Mech
C#
// C# program to convert degree to radian
using System;
class GFG{
// Function for conversion
static double Convert(double degree)
{
double pi = 3.14159265359;
return (degree * (pi / 180));
}
// Driver code
public static void Main()
{
double degree = 30;
double radian = Convert(degree);
Console.Write("{0:F6}", radian);
}
}
// This code is contributed by Code_Mech
Javascript
输出:
0.523599