三角函数表
输入角的度数(比如1度,30度,100度),计算出对应的正弦,余弦,正切,余切,正割,余割(保留4位小数)。#include<stdio.h> #include<math.h> int main() { const double pi=acos(-1.0); double x,r; double s,c,t; printf("请输入角的度数:"); scanf("%lf",&x); r=x*pi/180; s=sin(r); c=cos(r); t=tan(r); printf("sin=%f,cos=%f\n",s,c); printf("tan=%f\n",t); return 0; }
[此贴子已经被作者于2018-6-10 22:09编辑过]
#include<stdio.h> #include<math.h> int main() { const double pi=acos(-1.0); double x,r; double s,c,t,ctg,sec,csc; printf("请输入角的度数:"); scanf("%lf",&x); r=x*pi/180; s=sin(r); c=cos(r); t=tan(r); ctg=cos(r)/sin(r); sec=1/cos(r); csc=1/sin(r); printf("正弦值sin=%f\n",s); printf("余弦值cos=%f\n",c); printf("正切tan=%f\n",t); printf("余切ctg=%f\n",ctg); printf("正割sec=%f\n",sec); printf("余割csc=%f\n",csc); return 0; }
#include<stdio.h> #include<math.h> int main() { const double pi=acos(-1.0); double r,x; double s,c,t,ctg,sec,csc; int i=0; printf("请输入角的度数:"); scanf("%lf",&x); r=x*pi/180; printf("计算什么?\n"); printf("1.正弦值 2.余弦值 3.正切值\n"); printf("4.余切值 5.正割值 6.余割值\n"); scanf("%d", &i); switch (i) { case 1: s=sin(r); printf("正弦值sin=%f\n",s); break; case 2: c=cos(r); printf("余弦值cos=%f\n",c); break; case 3: t=tan(r); printf("正切值tan=%f\n",t); break; case 4: ctg=cos(r)/sin(r); printf("余切值ctg=%f\n",ctg); break; case 5: sec=1/cos(r); printf("正割值sec=%f\n",sec); break; case 6: csc=1/sin(r); printf("余割值csc=%f\n",csc); break; } return 0; }
#include<math.h> #include<stdio.h> int main() { int n=1; float x; double sum ,term; printf("input x:"); scanf("%f",&x); sum=x; term=x; do{ term=-term*x*x/((n+1)*(n+2)); sum=sum+term; n=n+2; } while (fabs(term)>=1e-3); printf("sin(x)=%lf\n",sum); return 0; }