C++教程
C++控制语句
C++函数
C++数组
C++指针
C++对象
C++继承
C++多态
C++抽象
C++常用
C++ STL教程
C++迭代器
C++程序

C++ Math tanh()

C++ Math tanh()

该函数计算以弧度表示的角度的双曲正切。
Math 上
tanhx = ex-e-x/ ex+e-x 

语法

假设角度为" x":
float tanh(float x);
double tanh(double x);
long double tanh(long double x);
double tanh(integral x);

参数

x : 要计算其双曲正切值的值。

返回值

它返回x的双曲正切。

示例1

让我们看一下x的值为整数类型的简单示例。
#include <iostream>
#include<math.h>
using namespace std;
 int main()
{
    int degree =60;
    float x = degree*3.14/180;
    std::cout << "Value of degree is : " <<degree<< std::endl;
    cout<<"tanh(x) : "<<tanh(x);
    return 0;
}
输出:
Value of degree is : 60
tanh(x) : 0.780507   
在此示例中,tanh(x)函数计算x的双曲正切并返回值0.78、

示例2

让我们看一下简单x的值为浮点型时的示例。
#include <iostream>
#include<math.h>
using namespace std;
int main()
{
    float degree = 45.2;
    float x = degree*3.14/180;
    std::cout << "Value of degree is : " <<degree<< std::endl;
    cout<<"tanh(x) : "<<tanh(x);
    return 0;
}
输出:
Value of degree is : 45.2
tanh(x) : 0.657552   
在此示例中,tanh(x)函数计算x的双曲正切值并返回值0.65、

昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4