C++ STL 中的 sinh() 函数
sinh() 函数返回给定角度(以弧度为单位)的双曲正弦值。它是 C++ STL 中的内置函数。
sinh() 函数的语法如下所示。
sinh(var)
从语法中可以看出,函数 sinh() 接受一个数据类型为 float、double 或 long double 的参数 var。它返回 var 的双曲正弦值。
一个在 C++ 中展示 sinh() 用法的程序如下所示。
实例
#include <iostream>
#include <cmath>
using namespace std;
int main() {
double d = 5, ans;
ans = sinh(d);
cout << "sinh("<< d <<") = " << ans << endl;
return 0;
}输出
sinh(5) = 74.2032
在上述程序中,首先初始化变量 d。然后使用 sinh() 找出 d 的双曲正弦值并存储在 ans 中。最后,显示 ans 的值。以下代码片段展示了此过程。
double d = 5, ans;
ans = sinh(d);
cout << "sinh("<< d <<") = " << ans << endl;如果以度为单位提供值,则在使用 sinh() 函数之前,需要将其转换为弧度,原因是它返回给定角度(以弧度为单位)的双曲正弦值。展示此过程的程序如下。
实例
#include <iostream>
#include <cmath>
using namespace std;
int main() {
double degree = 60, ans;
degree = degree * 3.14159/180;
ans = sinh(degree);
cout << "sinh("<<degree<<") = "<< ans << endl;
return 0;
}输出
sinh(1.0472) = 1.24937
在上述程序中,值以度为单位给出。因此将其转换成弧度,然后使用 sinh() 获得双曲正弦。最后,显示输出。如下面代码片段所示。
double degree = 60, ans;
degree = degree * 3.14159/180;
ans = sinh(degree);
cout << "sinh("<<degree<<") = " << ans << endl;
广告
数据结构
网络通信
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 语言编程
C++
C#
MongoDB
MySQL
Javascript
PHP