用c实现简单的循环输入输出
三角函数计算
#include <stdio.h>
#include <math.h>
int main()
{
while(1)
{
// assign constant
double pi = 3.14159265358979323846264338327;
double angle;
// get input
printf("enter a angle:\n");
scanf("%lf",&angle);
double theta = angle/180*pi;
double test_value = 1-theta*theta/2;
double x = cos(theta);
double l1 = 0.5, l2 = 1;
// formula
double result = sqrt(l1*l1+l2*l2 - 2*l1*l2*x);
printf("result: %f\n",result);
}
return 0;
}