cbrt(x)函数详解

首页 / C++入门教程 / cbrt(x)函数详解

此函数用于查找给定数字的立方根。

Cube root of a number : arg

cbrt - 语法

double cbrt(double arg);
float cbrt(float arg);
long double cbrt(long double arg);
double cbrt(integral arg);

cbrt - 参数

arg : 它是float或整数类型的值。

cbrt - 返回值

它返回给定数字arg的立方根。

cbrt - 例子1

让我们看一个简单的示例,其中参数" arg"为整数类型

链接:https://www.learnfk.comhttps://www.learnfk.com/c++/cpp-math-cbrt-function.html

来源:LearnFk无涯教程网

#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

cbrt - 例子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

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

技术教程推荐

从0开始学大数据 -〔李智慧〕

玩转Spring全家桶 -〔丁雪丰〕

大规模数据处理实战 -〔蔡元楠〕

Java性能调优实战 -〔刘超〕

A/B测试从0到1 -〔张博伟〕

Python自动化办公实战课 -〔尹会生〕

基于人因的用户体验设计课 -〔刘石〕

AI大模型之美 -〔徐文浩〕

给程序员的写作课 -〔高磊〕

好记忆不如烂笔头。留下您的足迹吧 :)