欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

c語(yǔ)言求余弦函數(shù)值,余弦函數(shù)C語(yǔ)言

C語(yǔ)言:使用函數(shù)求余弦函數(shù)的近似值

double?funcos(double?e,?double?x)

成都創(chuàng)新互聯(lián)堅(jiān)持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:網(wǎng)站制作、成都做網(wǎng)站、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時(shí)代的長(zhǎng)沙縣網(wǎng)站設(shè)計(jì)、移動(dòng)媒體設(shè)計(jì)的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!

{

if(e0)

{

int?i=0;

double?item=1;

double?cosx=0;

while(fabs(item)=e)

{

cosx+=item;

i++;

item*=-1*x*x/(2*i*(2*i-1))

}

return?cosx;

}

else

return?-2;

}

C語(yǔ)言求余弦值

唉,程序?qū)懙孟喈?dāng)不規(guī)范,看著好頭疼;函數(shù)應(yīng)該放在main外面……

#includestdio.h

#includemath.h

double jiecheng(int n)

{

int i;

double sum=1;

for(i=1;i=n;i++)

{

sum=sum*i;

}

return sum;

}

double fang(int x,int n)

{

double sum;

sum=pow(x,n);

return sum;

}

int main(void)

{

int j=1;

double x,e,count=0;

printf("e: ");

scanf("%lf",e);

printf("x: ");

scanf("%lf",x);

do{

count=count+(pow(-1,j-1))*fang(x,2*(j-1))/jiecheng(2*(j-1));

}while (fang(x,2*(j-1))/jiecheng(2*(j-1))e);

printf("%lf",count);

}

//可以運(yùn)行了,但是答案輸出來(lái)還是有問(wèn)題……自己查查你的算法,我就不看了,暈的慌

C語(yǔ)言(C++)?自己編寫求余弦值的程序。

#includestdio.h

#define

pi

3.14159265

//pi定義

double

mypow(double,int);

//自定義指數(shù)函數(shù)

int

mult(int);

//階乘函數(shù)

double

mysin(double);

//sin函數(shù)

double

mycos(double);

//cos函數(shù)

double

mypow(double

x,int

n)

{

int

i;

double

result=1;

if(n0)

for(i=1;i=n;i++)

result*=x;

return

result;

}

int

mult(int

n)

{

int

i;

int

result=1;

if(n0)

for(i=1;i=n;i++)

result*=i;

return

result;

}

double

mysin(double

x)

{

int

flag=1;//標(biāo)志正負(fù)

int

i;

double

result=0;

while(x=2*pi)

x-=2*pi;

while(x0)

x+=2*pi;

if(xpi)

{

x=2*pi-x;

flag=-flag;

}

if(xpi/2)

//將任意弧度轉(zhuǎn)化到[0,pi/2]

x=pi-x;

if(xpi/4)

//[pi/4,pi/2]調(diào)用cosX在[0,pi/4]求解,減少誤差

return

flag*mycos(pi/2-x);

for(i=0;i10;i++)//taylor展開

{

result+=((double)1)*mypow(x,2*i+1)*mypow(-1,i)/mult(2*i+1);

}

return

flag*result;

}

double

mycos(double

x)//與sin函數(shù)過(guò)程類似

{

int

flag=1;

int

i;

double

result=0;

while(x=2*pi)

x-=2*pi;

while(x0)

x+=2*pi;

if(x1.5*pi)

x=2*pi-x;

if(xpi/2

x=pi)

{

x=pi-x;

flag=-flag;

}

if(xpi

x=1.5*pi)

{

x-=pi;

flag=-flag;

}

if(xpi/4)

return

flag*mysin(pi/2-x);

for(i=0;i10;i++)

{

result+=((double)1)*mypow(x,2*i)*mypow(-1,i)/mult(2*i);

}

return

flag*result;

}

int

main()//測(cè)試程序

{

int

x;

while(1)

{

scanf("%d",x);//可以輸入任意一個(gè)角度(角度制),-1終止程序

printf("cosx=%lf\n",mycos(x*pi/180));//轉(zhuǎn)換成弧度,再調(diào)用前面的函數(shù)。

printf("sinx=%lf\n",mysin(x*pi/180));

if(x==-1)

break;

}

return

0;

}

C語(yǔ)言求余弦

#includestdio.h

#includemath.h

main()

{

int x,n;

scanf("%d",n);

x=n;

printf("%.4f",cos(x));

getch();

}

如何用C語(yǔ)言中專門的數(shù)學(xué)算法實(shí)現(xiàn)正弦,余弦函數(shù)的計(jì)算

頭文件包含。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;

}

如何在C語(yǔ)言中解決正弦或余弦函數(shù)的表示方法我是一個(gè)

如何在C語(yǔ)言中解決正弦或余弦函數(shù)的表示方法我是一個(gè)?頭文件包含。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。

標(biāo)題名稱:c語(yǔ)言求余弦函數(shù)值,余弦函數(shù)C語(yǔ)言
文章URL:http://chinadenli.net/article20/dsiohco.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供用戶體驗(yàn)微信公眾號(hào)營(yíng)銷型網(wǎng)站建設(shè)網(wǎng)站內(nèi)鏈ChatGPT定制開發(fā)

廣告

聲明:本網(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í)需注明來(lái)源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)