當前位置:首頁 » 編程語言 » c語言中的三角函數

c語言中的三角函數

發布時間: 2022-07-05 20:39:48

c語言三角函數

幫你更正一下: int main() { const double pi=3.14; //定義pi的值 double a; a=sin(45*pi/180); //角度轉化為弧度 printf("%f",a); //printf的正確格式 }

Ⅱ 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語言 三角函數 高手請進!

對於matlab,三角函數默認是以弧度為單位,如果在實數范圍內討論,反餘弦函數的定義域當然有范圍限制,一旦超出[-1, 1]的范圍,就只能得到虛數值。

Ⅳ 用C語言實現三角函數及反三角函數怎麼實現

包含頭文件math.h,然後就可以使用sin、asin等這些庫函數了,那些三角函數都有,直接引用即可。注意它們的輸入參數是double型或double型弧度。

Ⅳ 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語言中怎麼計算三角函數全部的程序代碼

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 ", x, y );

y = sinh( x );

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

y = cos( x );

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

y = cosh( x );

printf( "cosh( %f ) = %f ",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語言實現三角函數的計算

包含頭文件math.h後,所有三角函數的庫函數就都可以直接引用了。比如求x的正弦就用sin(x),它返回一個double值。注意x以弧度計……

Ⅷ C語言中計算三角函數

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

#definePI3.14159265

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

Ⅸ 如何用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語言中的三角函數計算需要將角度轉弧度,,比如以下代碼是計算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);
}

熱點內容
linux查看所屬組 發布:2025-03-13 09:28:32 瀏覽:982
電腦mc181聯機伺服器 發布:2025-03-13 09:20:48 瀏覽:681
辦公用文件夾種類 發布:2025-03-13 09:10:45 瀏覽:154
反編譯鎖屏密碼 發布:2025-03-13 09:10:36 瀏覽:98
編程韓信點兵 發布:2025-03-13 09:09:02 瀏覽:66
如何查看別人的wifi密碼 發布:2025-03-13 08:53:00 瀏覽:777
伺服器裝機地址 發布:2025-03-13 08:47:28 瀏覽:117
一個中學的配置是什麼 發布:2025-03-13 08:46:29 瀏覽:120
phpmysql編譯pdo 發布:2025-03-13 08:46:25 瀏覽:844
sql調優工具 發布:2025-03-13 08:41:32 瀏覽:76