在math.h這個(gè)函數(shù)庫(kù)里面有cos(double x)這個(gè)函數(shù),返回x的余弦值!
創(chuàng)新互聯(lián)建站主營(yíng)滄源網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營(yíng)網(wǎng)站建設(shè)方案,重慶App定制開發(fā),滄源h5微信平臺(tái)小程序開發(fā)搭建,滄源網(wǎng)站營(yíng)銷推廣歡迎滄源等地區(qū)企業(yè)咨詢
C語(yǔ)言里sin函數(shù)和cos函數(shù)是C標(biāo)準(zhǔn)數(shù)學(xué)函數(shù)庫(kù)中的函數(shù),調(diào)用需要引入math.h頭文件。
一、sin()?函數(shù)描述:
C 庫(kù)函數(shù) double sin(double x) 返回弧度角 x 的正弦。sin() 函數(shù)的聲明:double sin(double x)。
參數(shù):x -- 浮點(diǎn)值,代表了一個(gè)以弧度表示的角度。
返回值:該函數(shù)返回 x 的正弦。
二、cos() 函數(shù)描述:
cos() 函數(shù)的功能是求某個(gè)角的余弦值。cos()?函數(shù)的聲明:double cos(double x)。
參數(shù):x -- 浮點(diǎn)值,代表了一個(gè)以弧度表示的角度。
返回值:該函數(shù)返回 x 的余弦。
擴(kuò)展資料:
相關(guān)的三角函數(shù):
double asin (double); 結(jié)果介于[-PI/2,PI/2]
double acos (double); 結(jié)果介于[0,PI]
double atan (double); 反正切(主值),結(jié)果介于[-PI/2,PI/2]
double atan2 (double,double); 反正切(整圓值),結(jié)果介于[-PI,PI]
參考資料來源:百度百科-math.h
首先:程序應(yīng)該這樣改!
#include
#include
main()
{
double
n;
double
b,c;
scanf("%lf",n);
b=sin(n);
c=cos(n);
printf("%.2lf\n%.2lf",b,c);
return
0;
}
其次,這里的n是弧度值,你說的90度應(yīng)該輸入的是pi/2,而不是90,如果希望輸入90的話,那就這樣改!
#include
#include
main()
{
int
s;
double
n,b,c;
scanf("%d",s);
n=3.1415926*(s/180.0);
b=sin(n);
c=cos(n);
printf("%.2lf\n%.2lf",b,c);
return
0;
}
頭文件包含。math.h
cos
:余弦函數(shù)
函數(shù)原型:double
cos(double
x);
頭文件:#includemath.h
是否是標(biāo)準(zhǔn)函數(shù):是
函數(shù)功能:求x的余弦值,這里,x為弧度。
返回值:計(jì)算結(jié)果的雙精度值。
例程如下:
求cosx。
#include
stdio.h
#include
math.h
int
main(void)
{
double
result;
double
x
=
M_PI;
result
=
cos(x);
printf("cos(PI)
is
%lf\n",
result);
return
0;
}
sin:正弦函數(shù)
函數(shù)原型:double
sin(double
x);
頭文件:#includemath.h
是否是標(biāo)準(zhǔn)函數(shù):是
函數(shù)功能:求x的正弦值,這里,x為弧度。
返回值:計(jì)算結(jié)果的雙精度值。
例程如下:
求sinx。
#include
stdio.h
#include
math.h
int
main(void)
{
float
x;
x=M_PI/2;
printf("sin(PI/2)=%f",sin(x));
getchar();
return
0;
}
當(dāng)前題目:c語(yǔ)言正余弦函數(shù)怎么輸出,c語(yǔ)言輸出正弦曲線
鏈接分享:http://jinyejixie.com/article22/hseojc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站導(dǎo)航、面包屑導(dǎo)航、微信小程序、網(wǎng)站維護(hù)、網(wǎng)站內(nèi)鏈、定制網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)