C ++中的cbrt()函數(shù)返回?cái)?shù)字的立方根。
?x = cbrt(x)
此函數(shù)在<cmath>頭文件中定義。
double cbrt(double x); float cbrt(float x); long double cbrt(long double x); double cbrt(T x); // For integral type
cbrt()函數(shù)采用一個(gè)要計(jì)算其立方根的參數(shù)。
cbrt()函數(shù)返回給定參數(shù)的立方根。
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double x = -1000.0, result;
result = cbrt(x);
cout << "-1000 的立方根是 " << result << endl;
return 0;
}運(yùn)行該程序時(shí),輸出為:
-1000的立方根是 -10
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
long x = 964353422;
double result = cbrt(x);
cout << "964353422的立方根是 " << result << endl;
return 0;
}運(yùn)行該程序時(shí),輸出為:
964353422的立方根是 987.974