求sin的:參考下
網(wǎng)站建設(shè)哪家好,找成都創(chuàng)新互聯(lián)!專注于網(wǎng)頁設(shè)計(jì)、網(wǎng)站建設(shè)、微信開發(fā)、小程序開發(fā)、集團(tuán)企業(yè)網(wǎng)站建設(shè)等服務(wù)項(xiàng)目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了白云免費(fèi)建站歡迎大家使用!
#includestdio.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/b0.0000001) break;
else
{
if(count%2==0)
sum-=a/b;
else sum+=a/b;
}
}
printf("%lf\n",sum);
}
在調(diào)用三角函數(shù)之前先把角度換算成弧度,調(diào)用反三角函數(shù)之后把弧度換算成角度就可以了.可以用 pi = 4.0 * atan(1) 算出pi,用 a = h * 180.0/pi 算角度,用 h = a * pi /180 算弧度.
調(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;
}
要用弧度計(jì)算的,另外,pintf語句中,應(yīng)該是"%lf",不是"f%"
sin()是三角函數(shù),參數(shù)使用的是弧度,不是度。
asin()才是反三角函數(shù)。
資料 :
NAME
asin, asinf, asinl - arc sine function
SYNOPSIS
#include math.h
double asin(double x);
float asinf(float x);
long double asinl(long double x);
Link with -lm.
DESCRIPTION
The asin() function calculates the arc sine of x; that is the value
whose sine is x. If x falls outside the range -1 to 1, asin() fails
and errno is set.
RETURN VALUE
The asin() function returns the arc sine in radians and the value is
mathematically defined to be between -PI/2 and PI/2 (inclusive).
當(dāng)前文章:三角函數(shù)在c語言定義,三角函數(shù)用c語言怎么表示
本文網(wǎng)址:http://chinadenli.net/article32/hohpsc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站收錄、虛擬主機(jī)、ChatGPT、服務(wù)器托管、軟件開發(fā)、App開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)