摘要:
Power of Two: Given an integer, write a function to determine if it is a power of two. 题意:给定一个整数,判断其是否是2幂次方。 思路:如果一个整数是2的幂次方的话,用二进制可以表示为100…的形式,如8可以表示为100。在二进制的表示形式下只有一个1。判断n的2进制中1的个数。 代码: public bool... 阅读全文
posted @ 2016-01-12 19:40
Lewisr
阅读(112)
评论(0)
推荐(0)
摘要:
Happy Number: Write an algorithm to determine if a number is "happy". A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of ... 阅读全文
posted @ 2016-01-12 19:33
Lewisr
阅读(191)
评论(0)
推荐(0)

浙公网安备 33010602011771号