首页 > 技术文章 > C ++中的三角函数

Jack-Elvis 2022-04-25 18:03 原文

C ++中的三角函数

    用于三角函数的计算等计算余弦,正弦,正切值,以及反三角函数求对应的弧度制角度。

                                                   

 1 // C++ code to demonstrate the example of 
 2 // trigonometric functions
 3  
 4 #include <iostream>
 5 #include <cmath>
 6 using namespace std;
 7  
 8 // main() section
 9 int main()
10 {
11     float x;
12     float y;
13     
14     x = 0.25;
15     cout<<"cos("<<x<<") : "<<cos (x)<<endl;
16     cout<<"sin("<<x<<") : "<<sin (x)<<endl;
17     cout<<"tan("<<x<<") : "<<tan (x)<<endl;
18     cout<<"acos("<<x<<"): "<<acos(x)<<endl;
19     cout<<"asin("<<x<<"): "<<asin(x)<<endl;
20     cout<<"atan("<<x<<"): "<<atan(x)<<endl;
21     y = 1.0;
22     cout<<"atan2("<<y<<","<<x<<"): "<<atan2(y,x)<<endl;    
23     
24     return 0;
25 }

 

推荐阅读