新聞中心
怎樣用c語(yǔ)言編寫(xiě)一個(gè)程序用來(lái)輸出正弦函數(shù)值
首先:程序應(yīng)該這樣改!
創(chuàng)新互聯(lián)從2013年開(kāi)始,先為金東等服務(wù)建站,金東等地企業(yè),進(jìn)行企業(yè)商務(wù)咨詢服務(wù)。為金東企業(yè)網(wǎng)站制作PC+手機(jī)+微官網(wǎng)三網(wǎng)同步一站式服務(wù)解決您的所有建站問(wèn)題。
#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是弧度值,你說(shuō)的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;
}
怎樣用c語(yǔ)言畫(huà)正弦函數(shù)
1、首先,打開(kāi)VS2019,并且創(chuàng)建一個(gè)C語(yǔ)言源文件,會(huì)看到如下的頁(yè)面。
2、鼠標(biāo)在下圖紅色圈所示的區(qū)域單擊一下。
3、之后,再按Enter鍵,會(huì)看到新的一行。
4、在這一行中輸入:#includemath.h。
5、接著,在void main()中去定義一個(gè)單精度型變量。
6、定義完回車(chē)后,輸入a=sin(90);注意,90指的是90弧度。
7、再次回車(chē),輸入printf("%f",a);。
8、可以按F5鍵去運(yùn)行這段程序,會(huì)看到如下的結(jié)果。即90弧度的正弦值約為0.893997。
正弦函數(shù)C語(yǔ)言編程
#include stdio.h
#include math.h
#define EX 0.000001
#define PI 3.14159265
int main()
...{
double x=0.0, temp=1.0, sin=0.0;
int i;
printf("Please input a degree:");
scanf("%lf",x);
x=x*PI/180;
temp=x;
i=0 ;
while ( fabs(temp) EX ) ...{
sin += temp;
i += 2;
temp = (-1) * temp*x*x/( (i+1)*(i) );
}
printf("sin(%lf) = %lf ",x,sin);
printf("The number is %d ",i);
return 0;
}
本文名稱:c語(yǔ)言編寫(xiě)正弦函數(shù) c語(yǔ)言正弦函數(shù)怎么用
鏈接分享:http://biofuelwatch.net/article/ddgighp.html