此函數用於查找給定數字的立方根。
考慮一個參數 'arg':
Cube root of a number:âarg
用法
語法是:
double cbrt(double arg);
float cbrt(float arg);
long double cbrt(long double arg);
double cbrt(integral arg);
參數
arg:它是浮點型或整數型的值。
返回值
它返回給定數字 arg 的立方根。
例子1
當參數 'arg' 是整數類型時,讓我們看一個簡單的例子
#include <iostream>
#include<cmath>
using namespace std;
int main()
{ int arg=8;
std::cout << "Cube root of a number is:" <<cbrt(arg);
return 0;
}
輸出:
Cube root of a number is:2
例子2
當參數 'arg' 是浮點類型時,讓我們看一個簡單的例子。
#include <iostream>
#include<cmath>
using namespace std;
int main()
{
float arg=12.8;
std::cout << "Cube root of a number is:" <<cbrt(arg);
return 0;
}
輸出:
Cube root of a number is:2.33921
相關用法
- C++ Math cosh()用法及代碼示例
- C++ Math cos()用法及代碼示例
- C++ Math ceil()用法及代碼示例
- C++ Math copysign()用法及代碼示例
- C++ Math scalbn()用法及代碼示例
- C++ Math acosh()用法及代碼示例
- C++ Math asinh()用法及代碼示例
- C++ Math isgreater()用法及代碼示例
- C++ Math fabs()用法及代碼示例
- C++ Math islessgreater()用法及代碼示例
- C++ Math log2()用法及代碼示例
- C++ Math nearbyint()用法及代碼示例
- C++ Math tan()用法及代碼示例
- C++ Math log()用法及代碼示例
- C++ Math nextafter()用法及代碼示例
- C++ Math fdim()用法及代碼示例
- C++ Math isfinite()用法及代碼示例
- C++ Math erfc()用法及代碼示例
- C++ Math sinh()用法及代碼示例
- C++ Math scalbln()用法及代碼示例
注:本文由純淨天空篩選整理自 C++ Math cbrt()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。