标签:次方 exp code else 浮点 lse item solution nbsp
求base的exponent次方,exponent有两种可能性,
输出结果;
# -*- coding:utf-8 -*- class Solution: def Power(self, base, exponent): # write code here resault = 1 if exponent>0: for i in range(0,exponent): resault = resault*base elif exponent<0: exponentabs = abs(exponent) for i in range(0,exponentabs): resault = resault/base return resault
# -*- coding:utf-8 -*- class Solution: def reOrderArray(self, array): # write code here ji = [] ou = [] for i in array: if i %2 ==0: ou.append(i) else: ji.append(i) return ji+ou
剑指offer-数值的整数次方-调整数组顺序使奇数位于偶数前面-代码的完整性-python
标签:次方 exp code else 浮点 lse item solution nbsp
原文地址:https://www.cnblogs.com/ansang/p/12041877.html