新聞中心
如何用C語(yǔ)言實(shí)現(xiàn)三角函數(shù)的計(jì)算
math.h里的三角函數(shù)用的單位是弧度,你貌似錯(cuò)在這里。 答案補(bǔ)充 Example
創(chuàng)新互聯(lián)建站是一家專注于做網(wǎng)站、成都網(wǎng)站建設(shè)與策劃設(shè)計(jì),鹿寨網(wǎng)站建設(shè)哪家好?創(chuàng)新互聯(lián)建站做網(wǎng)站,專注于網(wǎng)站建設(shè)十載,網(wǎng)設(shè)計(jì)領(lǐng)域的專業(yè)建站公司;建站業(yè)務(wù)涵蓋:鹿寨等地區(qū)。鹿寨做網(wǎng)站價(jià)格咨詢:028-86922220
/* 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\n", x, y );
y = sinh( x );
printf( "sinh( %f ) = %f\n",x, y );
y = cos( x );
printf( "cos( %f ) = %f\n", x, y );
y = cosh( x );
printf( "cosh( %f ) = %f\n",x, y );
} 答案補(bǔ)充 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語(yǔ)言編寫(xiě)三角函數(shù)
求sin的:參考下 #includestdio.h void main() { double x,a,b,sum=0; printf("請(qǐng)輸入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/b0.0000001) break; else { if(count%2==0) sum-=a/b; else sum+=a/b; } } printf("%lf\n",sum); }
用C語(yǔ)言實(shí)現(xiàn)三角函數(shù)及反三角函數(shù)怎么實(shí)現(xiàn)
#includestdio.h
#include math.h
void main()
{
double a,b,c,d;
scanf("%f,%f",b,d);
a=sin(b);/*這是三角函數(shù)*/
c=asin(d);/*這是反三角函數(shù)*/
printf("sin(b)=%f,asin(d)=%d",a,c);
}
其他三角函數(shù)如cos(x)什么的,可以直接用,前提有math.h的頭文件
本文標(biāo)題:c語(yǔ)言三角函數(shù)的的做法 如何在c語(yǔ)言中使用三角函數(shù)
本文網(wǎng)址:http://fisionsoft.com.cn/article/hgsjgp.html