c语言中的三角函数
Ⅰ c语言三角函数
帮你更正一下: int main() { const double pi=3.14; //定义pi的值 double a; a=sin(45*pi/180); //角度转化为弧度 printf("%f",a); //printf的正确格式 }
Ⅱ C语言怎样表示三角函数计算(注:要用“角度制”表示)编出代码
调用math.h中的三角函数,需要将角度值变换为弧度值,代码如下:
#include<stdio.h>
#include<math.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语言 三角函数 高手请进!
对于matlab,三角函数默认是以弧度为单位,如果在实数范围内讨论,反余弦函数的定义域当然有范围限制,一旦超出[-1, 1]的范围,就只能得到虚数值。
Ⅳ 用C语言实现三角函数及反三角函数怎么实现
包含头文件math.h,然后就可以使用sin、asin等这些库函数了,那些三角函数都有,直接引用即可。注意它们的输入参数是double型或double型弧度。
Ⅳ c语言编写三角函数
求sin的:参考下 #include<stdio.h> void main() { double x,a,b,sum=0; printf("请输入x的弧度值:\n"); scanf("%lf",&x); int i,j,count=0; for(i=1;;i+=2) { count++; a=b=1; for(j=1;j<=i;j++) { a*=x; b*=(double)j; } if(a/b<0.0000001) break; else { if(count%2==0) sum-=a/b; else sum+=a/b; } } printf("%lf\n",sum); }
Ⅵ C语言中怎么计算三角函数全部的程序代码
math.h里的三角函数用的单位是弧度,你貌似错在这里。 答案补充 Example
/* SINCOS.C: This program displays the sine, hyperbolic
* sine, cosine, and hyperbolic cosine of pi / 2.
*/
#include <math.h>
#include <stdio.h>
void main( void )
{
double pi = 3.1415926535;
double x, y;
x = pi / 2;
y = sin( x );
printf( "sin( %f ) = %f ", x, y );
y = sinh( x );
printf( "sinh( %f ) = %f ",x, y );
y = cos( x );
printf( "cos( %f ) = %f ", x, y );
y = cosh( x );
printf( "cosh( %f ) = %f ",x, y );
} 答案补充 Output
sin( 1.570796 ) = 1.000000
sinh( 1.570796 ) = 2.301299
cos( 1.570796 ) = 0.000000
cosh( 1.570796 ) = 2.509178
Parameter
x
Angle in radians
Ⅶ 如何用C语言实现三角函数的计算
包含头文件math.h后,所有三角函数的库函数就都可以直接引用了。比如求x的正弦就用sin(x),它返回一个double值。注意x以弧度计……
Ⅷ C语言中计算三角函数
#include<stdio.h>
#include<math.h>
#definePI3.14159265
intmain()
{
doubleans=sqrt((1-cos(PI/3.0))/2.0);
printf("%g ",ans);
return0;
}
Ⅸ 如何用C语言写三角函数
求sin的:参考下
#include<stdio.h>
void main()
{
double x,a,b,sum=0;
printf("请输入x的弧度值:\n");
scanf("%lf",&x);
int i,j,count=0;
for(i=1;;i+=2)
{
count++;
a=b=1;
for(j=1;j<=i;j++)
{
a*=x;
b*=(double)j;
}
if(a/b<0.0000001) break;
else
{
if(count%2==0)
sum-=a/b;
else sum+=a/b;
}
}
printf("%lf\n",sum);
}
Ⅹ C语言怎样表示三角函数计算(注:要用“角度制”表示)..
C语言中的三角函数计算需要将角度转弧度,,比如以下代码是计算sin()的值:
#include"stdio.h"
#include"math.h"
#define PI 3.1415926
main()
{
int i;
float t;
printf("请输入要计算的角度:");
scanf("%d",i);
t=sin(180*i/PI);
printf("sin(%d)=%f",i,t);
}