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

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

技术教程推荐

编译原理之美 -〔宫文学〕

分布式技术原理与算法解析 -〔聂鹏程〕

Service Mesh实战 -〔马若飞〕

编译原理实战课 -〔宫文学〕

成为AI产品经理 -〔刘海丰〕

技术面试官识人手册 -〔熊燚(四火)〕

陈天 · Rust 编程第一课 -〔陈天〕

手把手带你搭建秒杀系统 -〔佘志东〕

AI大模型企业应用实战 -〔蔡超〕

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