c語言求三角函數(shù)值 c語言三角形函數(shù)

C語言怎樣表示三角函數(shù)計算(注:要用“角度制”表示)

在調(diào)用三角函數(shù)之前先把角度換算成弧度,調(diào)用反三角函數(shù)之后把弧度換算成角度就可以了.可以用 pi = 4.0 * atan(1) 算出pi,用 a = h * 180.0/pi 算角度,用 h = a * pi /180 算弧度.

創(chuàng)新互聯(lián)公司于2013年開始,先為豐寧等服務(wù)建站,豐寧等地企業(yè),進行企業(yè)商務(wù)咨詢服務(wù)。為豐寧企業(yè)網(wǎng)站制作PC+手機+微官網(wǎng)三網(wǎng)同步一站式服務(wù)解決您的所有建站問題。

求三角函數(shù)的C語言算法!

從鍵盤輸入一個角度值,求出該角度的正弦值、余弦值和正切值。

#includeiostream

#includecmath

using namespace std;

const double pi(3.14159265);

void main()

{ double a,b;

cina;

b=a*pi/180;

cout"sin("a")="sin(b)endl;

cout"cos("a")="cos(b)endl;

cout"tan("a")="tan(b)endl;

}

求階乘

#includeiostream.h

int Factorial ( int ) ;

void main ()

{ int k ;

cout "Compute Factorial(k) , Please input k: " ;

cin k ;

cout k "! = " Factorial(k) endl ;

}

int Factorial ( int n )

{ if ( n == 0 )

return 1 ;

else

return n * Factorial ( n - 1 ) ;

}

x的n次方的函數(shù)

#include iostream

using namespace std;

double power (double x, int n);

void main(void)

{

cout "5 to the power 2 is " power(5,2) endl;

}

double power (double x, int n)

{

double val = 1.0;

while (n--)

val = val*x;

return(val);

}

C語言三角函數(shù)求值,

math.h里的三角函數(shù)用的單位是弧度,你貌似錯在這里。 答案補充 Example

/* SINCOS.C: This program displays the sine, hyperbolic

* sine, cosine, and hyperbolic cosine of pi / 2.

*/

#include math.h

#include stdio.h

void main( void )

{

double pi = 3.1415926535;

double x, y;

x = pi / 2;

y = sin( x );

printf( "sin( %f ) = %f\n", x, y );

y = sinh( x );

printf( "sinh( %f ) = %f\n",x, y );

y = cos( x );

printf( "cos( %f ) = %f\n", x, y );

y = cosh( x );

printf( "cosh( %f ) = %f\n",x, y );

} 答案補充 Output

sin( 1.570796 ) = 1.000000

sinh( 1.570796 ) = 2.301299

cos( 1.570796 ) = 0.000000

cosh( 1.570796 ) = 2.509178

Parameter

x

Angle in radians

c語言:鍵盤分別輸入三角函數(shù)名及角度,求對應(yīng)的三角函數(shù)值

#?include?stdio.h

#?include?math.h

#?define?pi?3.1415926

int?main(void)

{

double?a,n,result;

char?func_name[3];

printf("enter?the?name?of?triangle?function?:");

scanf("%s",func_name);

printf("enter?angel:");

scanf("%lf",a);

n=pi*a/180;

if?(strcmp(func_name,?"sin")?==?0)

result=sin(n);

if?(strcmp(func_name,?"cos")?==?0)

result=cos(n);

if?(strcmp(func_name,?"tan")?==?0)

result=tan(n);

printf("%0.2f\n",result);

return?0

;

}

C語言怎樣表示三角函數(shù)計算(注:要用“角度制”表示)編出代碼

調(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;

}

C語言中計算三角函數(shù)

#include?stdio.h

#include?math.h

#define?PI?3.14159265

int?main()

{

double?ans?=?sqrt((1-cos(PI/3.0))/2.0);

printf?("%g\n",?ans);

return?0;

}

文章名稱:c語言求三角函數(shù)值 c語言三角形函數(shù)
網(wǎng)頁網(wǎng)址:http://muchs.cn/article6/hgeiog.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供微信小程序、網(wǎng)站設(shè)計、云服務(wù)器、外貿(mào)建站營銷型網(wǎng)站建設(shè)、面包屑導(dǎo)航

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都定制網(wǎng)站網(wǎng)頁設(shè)計