圆周率为3.1415926,求45度、90度的余弦值
详细C++代码如下:
#include<iostream>#include<math.h>#include<conio.h>using namespace std;int main(){float x = 45.0;float y = 90.0;float PI = 3.1415926;float xh = PI * x / 180.00;float yh = PI * y / 180.00;float cosVal = cos(xh);printf("cos of %f is : %lfn", x, cosVal);cosVal = cos(yh);printf("cos of %f is : %lfn", y, cosVal);getch();return 0;}运行结果:
对应的C代码