Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> C++

Hàm sinh() trong C++ STL


Hàm sinh() trả về hyperbolic sine (sin hyperbolic) của góc cho bằng radian. Hàm có sẵn trong C++ STL.

Cú pháp:

sinh(var)

Tham số var kiểu float, double, long double. Trả về hyperbolic sine.

Ví dụ

#include <iostream>
#include <cmath>
using namespace std;

int main() {
    double d = 5, ans;
    ans = sinh(d);
    cout << "sinh(" << d << ") = " << ans << endl;
    return 0;
}

Kết quả

sinh(5) = 74.2032

Khởi tạo, tính sinh(), in kết quả.

double d = 5, ans;
ans = sinh(d);
cout << "sinh(" << d << ") = " << ans << endl;

Nhập độ, chuyển radian

#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;
}

Kết quả

sinh(1.0472) = 1.24937

Chuyển độ sang radian: nhân π/180. Sau đó tính sinh().

double degree = 60, ans;
degree = degree * 3.14159 / 180;
ans = sinh(degree);
cout << "sinh(" << degree << ") = " << ans << endl;