在转向实际解决方案之前,让我们尝试找出什么是度数,弧度及其关系。
弧度:弧度是角度量度的标准单位,在许多数学领域中都使用。单位圆弧的弧长在数值上等于其对角的弧度测量值。一弧度在57.3度以下。
度:度(通常为度数,以度数符号)表示的度数(完整度是指弧度,弧度或弧度),它是指平面角的度量,定义为使整个旋转度为360度。
关系2pi * rad = 360°可以使用弧长公式得出。
与该圆的半径相同长度的圆弧的对角为1弧度。圆周对角为2pi弧度。
因此,公式为:
degree = radian * (180/pi)
where, pi = 22/7
例子:
Input : radian = 20
Output : degree = 1145.4545454545455
Explanation: degree = 20 * (180/pi)
Input : radian = 5
Output : degree = 286.3636363636364
Explanation : degree = 20 * (180/pi)
注意:在此程序中,我们将pi的值设为3.14159,以获取所有三种语言的标准结果。
C
// C code to convert radian to degree
#include
// Function for convertion
double Convert(double radian){
double pi = 3.14159;
return(radian * (180/pi));
}
// Driver Code
int main(){
double radian = 5.0;
double degree = Convert(radian);
printf("%.5lf", degree);
return 0;
}
Java
// Java code to convert radian to degree
import java.io.*;
class GFG {
// Function for convertion
static double Convert(double radian){
double pi = 3.14159;
return(radian * (180/pi));
}
// Driver Code
public static void main (String[] args) {
double radian = 5.0;
double degree = Convert(radian);
System.out.println("degree = "+ degree);
}
}
Python3
# Python code to convert radian to degree
# Function for convertion
def Convert(radian):
pi = 3.14159
# Simply used the formula
degree = radian * (180/pi)
return degree
# Driver Code
radian = 5
print("degree =",(Convert(radian)))
C#
// C# code to convert radian to degree.
using System;
class GFG {
// Function for convertion
static double Convert(double radian){
double pi = 3.14159;
return(radian * (180 / pi));
}
// Driver Code
public static void Main () {
double radian = 5.0;
double degree = Convert(radian);
Console.Write("degree = " + degree);
}
}
// This code is contributed by Nitin Mittal.
PHP
Javascript
输出 :
286.47914
参考:
https://zh.wikipedia.org/wiki/弧度
https://zh.wikipedia.org/wiki/度数(角度)