剑指offer
数值的整数次方
相似的企业真题
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 64M,其他语言128M
热度指数:741508
本题知识点:
数学
算法知识视频讲解
校招时部分企业笔试将禁止编程题跳出页面,为提前适应,练习时请使用在线自测,而非本地IDE。
题目描述
给定一个double类型的浮点数base和int类型的整数exponent。求base的exponent次方。
保证base和exponent不同时为0
示例1
输入
复制
2,3
2,3
返回值
复制
8.00000
8.00000
上一题
下一题
登录
/
注册
我的提交
编辑器加载中...
public class Solution { public double Power(double base, int exponent) { } }
class Solution { public: double Power(double base, int exponent) { } };
# -*- coding:utf-8 -*- class Solution: def Power(self, base, exponent): # write code here
class Solution { public double Power(double thebase, int exponent) { // write code here } }
function Power(base, exponent) { // write code here } module.exports = { Power : Power };
function Power(base, exponent) { // write code here }
package main /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * @param base double浮点型 * @param exponent int整型 * @return double浮点型 */ func Power( base float64 , exponent int ) float64 { // write code here }
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # @param base double浮点型 # @param exponent int整型 # @return double浮点型 # class Solution def Power(base, exponent) # write code here end end
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * @param base double浮点型 * @param exponent int整型 * @return double浮点型 */ def Power(base: Double,exponent: Int): Double = { // write code here } }
object Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * @param base double浮点型 * @param exponent int整型 * @return double浮点型 */ fun Power(base: Double,exponent: Int): Double { // write code here } }
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * @param base double浮点型 * @param exponent int整型 * @return double浮点型 */ public double Power (double base, int exponent) { // write code here } }
/** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * @param base double浮点型 * @param exponent int整型 * @return double浮点型 */ export function Power(base: number, exponent: number): number { // write code here }
public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * @param base double浮点型 * @param exponent int整型 * @return double浮点型 */ func Power ( _ base: Double, _ exponent: Int) -> Double { // write code here } }
struct Solution{ } impl Solution { fn new() -> Self { Solution{} } /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * @param base double浮点型 * @param exponent int整型 * @return double浮点型 */ pub fn Power(&self, base: f64, exponent: i32) -> f64 { // write code here } }
2,3
8.00000