当前位置:首页 » 编程语言 » c语言求三角函数

c语言求三角函数

发布时间: 2023-02-01 01:21:27

① 如何用c语言实现三角函数的计算

包含头文件math.h后,所有三角函数的库函数就都可以直接引用了。比如求x的正弦就用sin(x),它返回一个double值。注意x以弧度计……

② 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语言怎样表示三角函数计算(注:要用“角度制”表示)

在调用三角函数之前先把角度换算成弧度,调用反三角函数之后把弧度换算成角度就可以了.可以用 pi = 4.0 * atan(1) 算出pi,用 a = h * 180.0/pi 算角度,用 h = a * pi /180 算弧度.

⑤ C语言求三角函数

sum = fun(x,y,z); //这里,应当接收函数的返回值
printf("f(x,y,z)=%f\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);
}

⑦ 求三角函数的C语言算法

从键盘输入一个角度值,求出该角度的正弦值、余弦值和正切值。
#include<iostream>
#include<cmath>
using namespace std;
const double pi(3.14159265);
void main()
{ double a,b;
cin>>a;
b=a*pi/180;
cout<<"sin("<<a<<")="<<sin(b)<<endl;
cout<<"cos("<<a<<")="<<cos(b)<<endl;
cout<<"tan("<<a<<")="<<tan(b)<<endl;
}
求阶乘
#include<iostream.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次方的函数
#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语言进行三角函数的计算,比如知道sinx=0.5,求cos和tanx。怎么写

在C的math.h是有专门的三角函数和反三角函数的。
所以
你这个
x=asin(0.5)
输出
cos(x)

tan(x)就可以了。

⑨ 求一个计算三角函数的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语言三角函数求值,

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

热点内容
python在服务器端开发 发布:2024-05-20 03:31:17 浏览:65
编程大冒险 发布:2024-05-20 03:19:27 浏览:636
阿瓦隆九个人怎么配置 发布:2024-05-20 02:57:47 浏览:757
sqlnotinexcept 发布:2024-05-20 02:53:10 浏览:341
激光切割编程教程难吗 发布:2024-05-20 02:49:57 浏览:925
sqlbool 发布:2024-05-20 02:49:57 浏览:721
如何把文件压缩到最小 发布:2024-05-20 02:25:03 浏览:452
javash脚本文件 发布:2024-05-20 01:43:11 浏览:830
安卓手机如何登陆刺激战场国际服 发布:2024-05-20 01:29:02 浏览:861
服务器核库怎么找 发布:2024-05-20 01:28:14 浏览:375