📅  最后修改于: 2023-12-03 15:29:07.129000             🧑  作者: Mango
cbrt()函数是C++ STL库中的数学函数之一,用于计算一个double类型数值的立方根。
double cbrt(double x);
x:一个double类型的数值。
返回x的立方根。
下面是使用cbrt()函数计算不同数值的立方根的示例。
#include <iostream>
#include <cmath>
int main() {
double a = 8.0;
std::cout << "The cbrt value of " << a << " is " << std::cbrt(a) << std::endl;
double b = -27.0;
std::cout << "The cbrt value of " << b << " is " << std::cbrt(b) << std::endl;
double c = 125.0;
std::cout << "The cbrt value of " << c << " is " << std::cbrt(c) << std::endl;
return 0;
}
输出:
The cbrt value of 8 is 2
The cbrt value of -27 is -3
The cbrt value of 125 is 5