📜  C++ STL中的asinh()函数

📅  最后修改于: 2021-05-30 17:55:30             🧑  作者: Mango

asinh()是C++ STL中的内置函数,它返回以弧度给出的角度的反双曲正弦值。

句法:

asinh(data_type x)

参数:该函数接受一个强制性参数x ,该参数以弧度指定反双曲线角。它可以是任何值,即负,正或零。该参数可以是double,float或long double数据类型。

返回值:该函数以弧度返回参数的反双曲正弦值。

下面的程序演示了上述函数:

程序1:

// C++ program to demonstrate
// the asinh() function
#include 
using namespace std;
  
int main()
{
    double x = 50.0;
  
    // Function call to calculate asinh(x) value
    double result = asinh(x);
  
    cout << "asinh(50.0) = " << result << " radians" << endl;
    cout << "asinh(50.0) = " << result * 180 / 3.141592
         << " degrees" << endl;
    return 0;
}
输出:
asinh(50.0) = 4.60527 radians
asinh(50.0) = 263.863 degrees

程式2:

// C++ program to demonstrate
// the asinh() function
#include 
using namespace std;
  
int main()
{
    int x = -50.0;
  
    // Function call to calculate asinh(x) value
    double result = asinh(x);
  
    cout << "asinh(-50.0) = " << result << " radians" << endl;
    cout << "asinh(-50.0) = " << result * 180 / 3.141592
         << " degrees" << endl;
    return 0;
}
输出:
asinh(-50.0) = -4.60527 radians
asinh(-50.0) = -263.863 degrees

错误和异常:当将字符串或字符作为参数传递时,该函数返回任何匹配函数来调用错误。
程序3:

// C++ program to demonstrate
// the asinh() function
#include 
using namespace std;
  
int main()
{
    string x = "gfg";
  
    // Function call to calculate asinh(x) value
    double result = asinh(x);
  
    cout << "asinh(50.0) = " << result << " radians" << endl;
    cout << "asinh(50.0) = " << result * 180 / 3.141592
         << " degrees" << endl;
    return 0;
}

输出 :

prog.cpp:11:25: error: no matching function for call to 'asinh(std::__cxx11::string&)'
  double result = asinh(x);
要从最佳影片策划和实践问题去学习,检查了C++基础课程为基础,以先进的C++和C++ STL课程基础加上STL。要完成从学习语言到DS Algo等的更多准备工作,请参阅“完整面试准备课程”