博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Pow(x, n)
阅读量:4074 次
发布时间:2019-05-25

本文共 395 字,大约阅读时间需要 1 分钟。

Pow(x, n)

Implement pow(xn).

Java代码:

public class Solution {    public double pow(double x, int n) {    if (x == 0) return 0;     if (x == 1) return 1;    if (n == 0) return 1;     if (n == 1) return x;    if (x == -1) return (n % 2) == 0 ? 1 : -1;     if (n < 0 ) return 1/ pow (x, -n);    if (n == 2) return x * x;    int halfPow = n/2;     return pow(pow(x,halfPow),2) * pow(x, n%2);     }}
 

转载地址:http://lnuni.baihongyu.com/

你可能感兴趣的文章
Unity StartCoroutine 和 yield return 深入研究
查看>>
Unity-Animator深入系列
查看>>
UNITY3D的变量初始化问题
查看>>
UNITY3D单词学习 speed和velocity的区别
查看>>
Unity3D中的线性插值Lerp()函数解析
查看>>
pitch yaw roll 的区别
查看>>
什么是UV?
查看>>
手机开启HDR后拍照有什么不同?
查看>>
图文详解Unity3D中Material的Tiling和Offset是怎么回事
查看>>
voxel 与 pixel
查看>>
vector3.forward和transform.forward的区别!
查看>>
HOLOLENS的空间管理
查看>>
unity3d 的Quaternion.identity和transform.rotation区别是什么
查看>>
【Unity3d】Ray射线初探-射线的原理及用法
查看>>
迄今最深入、最专业的Hololens评测结果,美国AR大咖艾迪·奥夫曼现身说法
查看>>
全息眼镜HoloLens可快速捕捉真人3D图像
查看>>
copy-paste component
查看>>
【Unity】矩阵运算
查看>>
理解向量运算
查看>>
正弦 sin 余弦 cos
查看>>