c语言里怎么求三角函数 c语言如何计算三角函数

C语言怎样表示三角函数计算(注:要用“角度制”表示)编出代码调用math.h中的三角函数,需要将角度值变换为弧度值,代码如下:
#includestdio.h
#includemath.h
#define PI 3.14159265359
int main()
{
float st,a;
scanf("%f",st);
a = st * PI/180;
printf("sin(st)=%f\n", sin(a));
printf("cos(st)=%f\n", cos(a));
return 0;
}
c语言cos和sin是怎么用的呢,网上说的太复杂了要用三角函数请在程序前面包含math.h,可以写:#includemath.h
由于cos和sin函数的参数和返回值都是double型的,请定义相关变量:double x,y;
由于cos和sin函数的参数都是弧度制的请注意将角度转换为弧度计算:
#define PI 3.1415926
x=45.0/180*PI; y=sin(x); //计算sin 45°的值
求三角函数的C语言算法!从键盘输入一个角度值 , 求出该角度的正弦值、余弦值和正切值 。
#includeiostream
#includecmath
using namespace std;
const double pi(3.14159265);
void main()
{double a,b;
cina;
b=a*pi/180;
cout"sin("a")="sin(b)endl;
cout"cos("a")="cos(b)endl;
cout"tan("a")="tan(b)endl;
}
求阶乘
#includeiostream.h
intFactorial ( int ) ;
voidmain ()
{ intk ;
cout"Compute Factorial(k) ,Please input k: " ;
cink ;
coutk"! = "Factorial(k)endl ;
}
intFactorial ( intn )
{ if ( n == 0 )
return1 ;
else
returnn * Factorial ( n - 1 ) ;
}
x的n次方的函数
#include iostream
using namespace std;
double power (double x, int n);
void main(void)
{
cout"5 to the power 2 is "power(5,2)endl;
}
double power (double x, int n)
{
double val = 1.0;
while (n--)
val = val*x;
return(val);
}
C语言求三角函数sum = fun(x,y,z);//这里,应当接收函数的返回值
printf("f(x,y,z)=%f\n",sum);
如何用C语言进行三角函数的计算,比如知道sinx=0.5,求cos和tanx 。怎么写在C的math.h是有专门的三角函数和反三角函数的 。
所以
你这个
x=asin(0.5)
输出
cos(x)

tan(x)就可以了 。
【c语言里怎么求三角函数 c语言如何计算三角函数】c语言里怎么求三角函数的介绍就聊到这里吧 , 感谢你花时间阅读本站内容,更多关于c语言如何计算三角函数、c语言里怎么求三角函数的信息别忘了在本站进行查找喔 。

    推荐阅读