sinx的c代码:
#include <stdio.h>
#include <math.h>
#include<stdlib.h>
#define eps 1e-6
int main()
{
double x,sinx,item;
int n=1,sign=-1;
printf("输入度数:\n");
scanf("%lf",&x);
while(x>360)
{
x=x-360;//让其值在0~360
}
x=x*3.14159/180;//转换成弧度
sinx=x;
item=x;
while(fabs(item)>eps)
{
item=item*x*x/((n+1)*(n+2))*sign;
sinx=sinx+item;
n=n+2;
}
printf("sinx=%lf\n",sinx);
system("pause");
return 0;
}
√x的c代码:
#include <stdio.h>
#include<stdlib.h>
//求绝对值
#define abs(x) (x)>0?(x):(-(x))
#define eps 1e-6
int main()
{
double val;
//value及精度
printf("Input value:");
scanf("%lf",&val);
if(val < 0 )
{
val*=-1;
}
double low,high;
if(val