C ++中的cbrt()函数返回数字的立方根。
∛x = cbrt(x)
此函数在<cmath>头文件中定义。
double cbrt(double x); float cbrt(float x); long double cbrt(long double x); double cbrt(T x); // For integral type
cbrt()函数采用一个要计算其立方根的参数。
cbrt()函数返回给定参数的立方根。
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double x = -1000.0, result;
result = cbrt(x);
cout << "-1000 的立方根是 " << result << endl;
return 0;
}运行该程序时,输出为:
-1000的立方根是 -10
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
long x = 964353422;
double result = cbrt(x);
cout << "964353422的立方根是 " << result << endl;
return 0;
}运行该程序时,输出为:
964353422的立方根是 987.974