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

用c語言求余弦函數(shù)弧長(zhǎng) c語言余弦值函數(shù)

用c語言程序編寫用下面中間公式方法求正弦和余弦的方法 并定義為函數(shù) 在main里面調(diào)用

#include?stdio.h

創(chuàng)新互聯(lián)主要從事做網(wǎng)站、網(wǎng)站設(shè)計(jì)、網(wǎng)頁設(shè)計(jì)、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)赤峰林西,十載網(wǎng)站建設(shè)經(jīng)驗(yàn),價(jià)格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):18982081108

#include?math.h

#define?P?3.1415927

double?sinx(double?x)?{

double?eps?=?1E-8,delta?=?x;

double?sgn?=?-1,sin?=?x,n?=?1;

double?nator?=?1;

while(fabs(delta)??eps)?{

nator?*=?(n?+?1.0)*(n?+?2.0);

delta?*=?x*x/nator;

sin?+=?sgn*delta;

sgn?=?-sgn;

n?+=?2;

}

return?sin;

}

double?cosx(double?x)?{

double?eps?=?1E-8,delta?=?1;

double?sgn?=?-1,cos?=?1,n?=?1;

double?nator?=?1;

while(fabs(delta)??eps)?{

nator?*=?n*(n?+?1.0);

delta?*=?x*x/nator;

cos?=?cos?+?sgn*delta;

sgn?=?-sgn;

n?+=?2;

}

return?cos;

}

int?main()?{

double?alpha;

int?T;

printf("測(cè)試次數(shù):");

scanf("%d",T);

while(T--)?{

printf("請(qǐng)輸入度數(shù):");

scanf("%lf",alpha);

alpha?*=?P/180;

printf("msin(%lf)?=?%lf\n",alpha,sinx(alpha));

printf("sin(%lf)?=?%lf\n",alpha,sin(alpha));//調(diào)用系統(tǒng)函數(shù)用于對(duì)比

printf("mcos(%lf)?=?%lf\n",alpha,cosx(alpha));

printf("cos(%lf)?=?%lf\n",alpha,cos(alpha));//調(diào)用系統(tǒng)函數(shù)用于對(duì)比

}

return?0;

}

C語言(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ù)過程類似

{

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語言求余弦

#includestdio.h

#includemath.h

main()

{

int x,n;

scanf("%d",n);

x=n;

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

getch();

}

如何用C語言中專門的數(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;

}

新聞標(biāo)題:用c語言求余弦函數(shù)弧長(zhǎng) c語言余弦值函數(shù)
標(biāo)題鏈接:http://chinadenli.net/article16/hhpodg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供全網(wǎng)營(yíng)銷推廣標(biāo)簽優(yōu)化網(wǎng)站維護(hù)網(wǎng)站建設(shè)品牌網(wǎng)站建設(shè)網(wǎng)站設(shè)計(jì)公司

廣告

聲明:本網(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)

外貿(mào)網(wǎng)站制作