Power of Four

Given an integer (signed 32 bits), write a function to check whether it is a power of 4.

Example:
Given num = 16, return true. Given num = 5, return false.

Follow up: Could you solve it without loops/recursion?

 /*************************************************************************
> File Name: LeetCode342.c
> Author: Juntaran
> Mail: Jacinthmail@gmail.com
> Created Time: 2016年05月10日 星期二 02时50分00秒
************************************************************************/ /************************************************************************* Power of Four Given an integer (signed 32 bits), write a function to check whether it is a power of 4. Example:
Given num = 16, return true. Given num = 5, return false. Follow up: Could you solve it without loops/recursion? ************************************************************************/ #include "stdio.h" int isPowerOfFour(int num) {
double tmp = log10(num)/log10();
return tmp == (int)tmp ? : ;
} int main()
{
int n = ;
int ret = isPowerOfFour(n);
printf("%d\n",ret); n = ;
ret = isPowerOfFour(n);
printf("%d\n",ret); return ;
}

最新文章

  1. 项目中的web api知识总结
  2. Serena Dimensions 介绍
  3. ODAC(V9.5.15) 学习笔记(十五)数据离线模式
  4. ios App优化
  5. VirtualBox中的Ubuntu没有权限访问共享文件夹/media/sf_bak
  6. C# 引用类型与值类型的区别
  7. 创建Material Design风格的Android应用--使用Drawable
  8. ajax——client访问webservice基本用法
  9. LayUI分页,LayUI动态分页,LayUI laypage分页,LayUI laypage刷新当前页
  10. vue 购物车练习
  11. 安卓开发学习笔记(一):如何用Android Stuidio导出apk文件?
  12. SpringBoot的国际化使用
  13. Java基础-对象的内存分配与初始化(一定要明白的干货)
  14. Linux之ssh登录
  15. 第二阶段团队冲刺——One
  16. u3d外部资源加载加密
  17. 【转】ArcGIS API for Silverlight/WPF 2.1学习笔记(二)
  18. Eclipse无法查看源码 提示source not found
  19. python3之Django内置模板标签和过滤器
  20. C++实现 逆波兰表达式计算问题

热门文章

  1. 关于P2P架构的网络游戏
  2. Python 发送邮件包含附件报表示例
  3. F5 刷新功能
  4. Linux的运行级别和chkconfig用法
  5. K - 最少拦截系统
  6. MVC神韵---你想在哪解脱!(十五)
  7. 正整数的n次方求和
  8. C#的枚举数(Enumerator)和可枚举类型(Enumerable)
  9. 深入浅出之Smarty模板引擎工作机制(二)
  10. 【转】shell脚本处理字符串的常用方法