C语言弧度转角度问题
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了C语言弧度转角度问题相关的知识,希望对你有一定的参考价值。
输入弧度算这个程序是对的,但是我想换成输入角度计算,换成第10行后面注释的那个,出来的答案是错的。--#include <stdio.h>#include <math.h>#define pi 3.1415926int main() int x,i; double numErator,sum,sign=1; double factor=1,factorial=1; scanf("%d",&x); sum = numErator= x; //角度:1.0*180/pi*x for (i = 3; fabs(factor)>=0.00001; i += 2) factorial *= (i-1)*i; numErator *= x*x; sign = -sign; factor = sign * numErator / factorial; sum += factor; printf("%lf", sum); return 0;
#include <stdio.h>#include <math.h>
#define pi 3.1415926
int main()
int i;
double numErator, sum, sign = 1;
double factor = 1, factorial = 1;
double x;
scanf("%lf", &x);
sum = numErator = x = x/180.0*pi;
for (i = 3; fabs(factor) >= 0.00001; i += 2)
factorial *= (i - 1) * i;
numErator *= x * x;
sign = -sign;
factor = sign * numErator / factorial;
sum += factor;
printf("%lf", sum);
return 0;
参考技术A #include <stdio.h>
#include <math.h>
#define pi 3.1415926
int main()
int i;
double x,numErator,sum,sign=1;
double factor=1,factorial=1;
scanf("%lf",&x);
x*=pi/180;
sum = numErator= x;
for (i = 3; fabs(factor)>=0.00001; i += 2)
factorial *= (i-1)*i;
numErator *= x*x;
sign = -sign;
factor = sign * numErator / factorial;
sum += factor;
printf("%lf", sum);
return 0;
参考技术B #include<stdio.h>
#define PI 3.14159265f
void main()
int i;
float ooo;
printf("输入角度请按1,输入弧度请按2\\n");
scanf("%d",&i);
switch(i)
case 1:
printf("输入角度:");
scanf("%f",&ooo);
printf("弧度为:%f\\n",(ooo/180)*PI);
break;
case 2:
printf("输入弧度:");
scanf("%f",&ooo);
printf("角度为:%f\\n",(ooo/PI)*180);
追问
问题都不看还复制来回答?
Qt中的角度转弧度
在Qt中,qAsin(),qAtan2()等三角函数的返回值是弧度而不是角度,因此要将弧度转化为角度。
弧度=角度*Pi/180
以qAtan()函数为例
qreal qAtan(qreal v)
Returns the arctangent of v as an angle in radians. Arctangent is the inverse operation of tangent.
See also qTan(), qAcos(), and qAsin().
其中radians表示弧度
以上是关于C语言弧度转角度问题的主要内容,如果未能解决你的问题,请参考以下文章