當前位置:首頁 » 編程語言 » c語言求三角函數值
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

c語言求三角函數值

發布時間: 2022-06-18 00:56:52

『壹』 求三角函數的c語言演算法!

我暈用得著這樣?

#include<math.h>

不行嗎?下圖是TCmath.h庫支持的函數

『貳』 C語言怎樣表示三角函數計算(註:要用「角度制」表示)編出代碼

調用math.h中的三角函數,需要將角度值變換為弧度值,代碼如下:
#include<stdio.h>
#include<math.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語言編寫三角函數

求sin的:參考下 #include<stdio.h> void main() { double x,a,b,sum=0; printf("請輸入x的弧度值:\n"); scanf("%lf",&x); int i,j,count=0; for(i=1;;i+=2) { count++; a=b=1; for(j=1;j<=i;j++) { a*=x; b*=(double)j; } if(a/b<0.0000001) break; else { if(count%2==0) sum-=a/b; else sum+=a/b; } } printf("%lf\n",sum); }

『肆』 求一個計算三角函數的C語言程序(不要使用C庫,要自己定義函數)

#include
#include
int main()
{
double n; //sin cos是函數,不能定義成變數
scanf("%lf",&n);
n=sin(n); //求n的sin()值,並返回給n
printf("%lf\n",n);//輸出n
return 0;
}

『伍』 C語言怎樣表示三角函數計算(註:要用「角度制」表示)..

C語言中的三角函數計算需要將角度轉弧度,,比如以下代碼是計算sin()的值:
#include"stdio.h"
#include"math.h"
#define PI 3.1415926
main()
{
int i;
float t;
printf("請輸入要計算的角度:");
scanf("%d",i);
t=sin(180*i/PI);
printf("sin(%d)=%f",i,t);
}

『陸』 C語言中計算三角函數

#include<stdio.h>
#include<math.h>

#definePI3.14159265

intmain()
{
doubleans=sqrt((1-cos(PI/3.0))/2.0);
printf("%g ",ans);
return0;
}

『柒』 C語言三角函數求值,

math.h里的三角函數用的單位是弧度,你貌似錯在這里。 答案補充 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