此函数计算弧度中数字的反余弦值。
假设数字是x。语法为:
float acos(float x); double acos(double x); long double acos(long double x); double acos(integral x);
x :要计算其反余弦的值。它应该在[-1,1]范围内。
参数 | 返回值 |
---|---|
-1≤x≤1 | (0,∏) |
x1 | Not a number |
让我们看一个简单的例子,当x的值大于1时。
#include <iostream> #include<math.h> using namespace std; int main() { float degree=90; float x=degree*3.14/180; std::cout << "Value of cosine is :" <<cos(x)<< std::endl; cout<<"Inverse of cosine is :"<<acos(x); return 0; }
输出:
Value of cosine is :0.000796274 Inverse of cosine is :nan
在此示例中,当x的值大于1时,acos()函数计算数字的反余弦值。
让我们看一个简单的例子,当x的值等于零时。
链接:https://www.learnfk.comhttps://www.learnfk.com/c++/cpp-math-acos-function.html
来源:LearnFk无涯教程网
#include <iostream> #include<math.h> using namespace std; int main() { float degree=0; float x=degree*3.14/180; std::cout << "Value of cosine is :" <<cos(x)<< std::endl; cout<<"Inverse of cosine is :"<<acos(x); return 0; }
输出:
Value of cosine is :1 Inverse of cosine is :1.5708
在此示例中,当x的值等于零时,acos()函数计算数字的反余弦值。
让我们看一个简单的例子,当x小于-1时。
#include <iostream> #include<math.h> using namespace std; int main() { float degree= -60; float x=degree*3.14/180; std::cout << "Value of cosine is :" <<cos(x)<< std::endl; cout<<"Inverse of cosine is :"<<acos(x); return 0; }
输出:
Value of cosine is :0.50046 Inverse of cosine is :nan
在此示例中,当x的值小于-1时,acos()函数计算数字的反余弦值。
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)