#includestdio.h
創(chuàng)新互聯(lián)公司2013年至今,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項(xiàng)目做網(wǎng)站、成都做網(wǎng)站網(wǎng)站策劃,項(xiàng)目實(shí)施與項(xiàng)目整合能力。我們以讓每一個(gè)夢(mèng)想脫穎而出為使命,1280元安福做網(wǎng)站,已為上家服務(wù),為安福各地企業(yè)和個(gè)人服務(wù),聯(lián)系電話:13518219792
#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的頭文件
math.h里的三角函數(shù)用的單位是弧度,你貌似錯(cuò)在這里。 ? 答案補(bǔ)充 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\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
1、C語言編寫三角函數(shù)有兩種方法,簡單點(diǎn)就是調(diào)用#includemath.h,里面有sin(x),cos(x),等各種三角函數(shù),返回值就是計(jì)算結(jié)果;難點(diǎn)就是自己寫函數(shù),利用的是三角函數(shù)按指數(shù)冪展開,相對(duì)復(fù)雜,也只是求個(gè)近似;
2、正弦定理里面求角x就容易了,定義了求出sin(x)后調(diào)用反三角函數(shù)求x即可
希望可以幫到你,如果滿意請(qǐng)采納!
調(diào)用math.h中的三角函數(shù),需要將角度值變換為弧度值,代碼如下:
#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;
}
求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語言如何編寫三角函數(shù) c語言如何編寫三角函數(shù)符號(hào)
文章轉(zhuǎn)載:http://muchs.cn/article6/doocdog.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設(shè)計(jì)公司、小程序開發(fā)、企業(yè)網(wǎng)站制作、面包屑導(dǎo)航、標(biāo)簽優(yōu)化、全網(wǎng)營銷推廣
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)