c语言编写sin函数问题 c语言编写sin函数的程序

怎样用c语言编写一个程序用来输出正弦函数值首先:程序应该这样改!
#include
#include
main()
{
double
n;
double
b,c;
scanf("%lf",n);
b=sin(n);
c=cos(n);
printf("%.2lf\n%.2lf",b,c);
return
0;
}
其次,这里的n是弧度值,你说的90度应该输入的是pi/2,而不是90,如果希望输入90的话,那就这样改!
#include
#include
main()
{
int
s;
double
n,b,c;
scanf("%d",s);
n=3.1415926*(s/180.0);
b=sin(n);
c=cos(n);
printf("%.2lf\n%.2lf",b,c);
return
0;
}
C语言编写sin函数?求教!#include"stdio.h"
#include"math.h"
double mysin(double x)
{double y=x,t=x,t1=x*x;
for(int i=2;fabs(t)1e-10;i =2)
{t*=-t1/(i*(i 1));
y =t;
}
return y;
}
int main()
{ double x;
scanf("%lf",x);
printf("%f\n",mysin(x));
return 0;
}
c语言不调用math库编写sin函数#includestdio.h
#include math.h
//先定义一个阶乘函数
double fac(double n){
double f=0;
if(n == 1 || n==0)
f =1;
else
f = fac(n-1)*n;
return f;
}
//一个指数函数(次方)
double kvat(double n,double ci){
double chengf=1;
for (int i=1; i=ci; i) {
chengf = chengf*n;
}
return chengf;
}
double sinus(double x){
int z =-1;
int j =1;
double sin=x;
for (j =3;fabs( kvat(x,j)/fac(j) )0.001 ; j =2) {
//printf("%lf\n",kvat(x, j));
sin =sinz*(kvat(x,j)/fac(j));
【c语言编写sin函数问题 c语言编写sin函数的程序】z = -z;
}
return sin;
}
int main(){
double jd,hudu;
scanf("%lf",jd);
hudu = (jd*M_PI)/180;//这里的M_PI在math库里就是 圆周率pai
printf( "%.3lf",sinus(hudu));
return 0;
}
c语言编写sin函数问题的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于c语言编写sin函数的程序、c语言编写sin函数问题的信息别忘了在本站进行查找喔 。

    推荐阅读